alexis-mignon / python-flickr-api

A python implementation of the Flickr API
BSD 3-Clause "New" or "Revised" License
367 stars 108 forks source link

Using Walker with user.getPhoto as an input #93

Closed lukrido closed 5 years ago

lukrido commented 6 years ago

Hello

I am working with Python3.6.5 and I have the following issue with the Walker feature.

`

getting w works

w = f.Photo.search(f.Photo.search, tags="animals")

getting y doesn't work

y = f.Walker(user.getPhotos())

but z works

z = f.Walker(f.Photo.search, tags="animals") `

Haga:get_focallength lukrido$ ./get_focallength.py Traceback (most recent call last): File "./get_focallength.py", line 13, in <module> z = f.Walker(w) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flickr_api/objects.py", line 2121, in __init__ self._curr_list = self.method(*self.args, **self.kwargs) TypeError: 'FlickrList' object is not callable

However, both user.getPhotos and Photo.search return a FlickList Any idea what I am doing wrong?

Thanks!

mtrovo commented 6 years ago

Walker method expects a function that returns a FlickrList, you're example is executing the function and passing its results to Walker that's why you're getting this error, removing the parenthesis should do the trick.

In [22]: f.Walker(user.getPhotos())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-22-e71220c17442> in <module>()
----> 1 f.Walker(user.getPhotos())
~/zeisch/python-flickr-api/flickr_api/objects.py in __init__(self, method, *args, **kwargs)
   2119         self.kwargs = kwargs
   2120
-> 2121         self._curr_list = self.method(*self.args, **self.kwargs)
   2122         self._info = self._curr_list.info
   2123         self._curr_index = 0
TypeError: 'FlickrList' object is not callable
In [23]: f.Walker(user.getPhotos)
Out[23]: <flickr_api.objects.Walker at 0x10d501c50>
In [24]: w = f.Walker(user.getPhotos)
In [25]: w.next()
Out[25]: Photo(id=b'24051561688', title=b'IMG_20180101...)