python-flickr-api icon indicating copy to clipboard operation
python-flickr-api copied to clipboard

photo.getSizes() returns string

Open Matthijz98 opened this issue 2 years ago • 3 comments

Hi maybe i am doing something wrong but why does photo.getSizes() returns a string?

def test(photoset_id)
        photoset = flickr_api.Photoset(id=photoset_id)
        walker = flickr_api.Walker(photoset.getPhotos)

        # Loop through the pages
        for api_photo in walker:
                for size in api_photo.getSizes():
                    print(type(size))  # <class 'str'>

Matthijz98 avatar Jan 02 '23 21:01 Matthijz98

This maps to the getSizes() API request, which means it likely returns a dict

https://www.flickr.com/services/api/flickr.photos.getSizes.html

beaufour avatar Jan 03 '23 14:01 beaufour

Yes i expected a dict as well but print(type(size)) # <class 'str'> said it is a string.

Matthijz98 avatar Jan 05 '23 09:01 Matthijz98

That's because the keys of the dictionary are strings, and you are iterating over the keys in that loop. Try print(type(api_photo.getSizes()).

beaufour avatar Jan 05 '23 13:01 beaufour