Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot like() user (can't get an object out of a generator) #127

Closed
nicshackle opened this issue Jan 5, 2017 · 1 comment
Closed

Cannot like() user (can't get an object out of a generator) #127

nicshackle opened this issue Jan 5, 2017 · 1 comment

Comments

@nicshackle
Copy link

session = pynder.Session(FBTOKEN)
users = session.nearby_users()
for user in users[:5]:
    print user.like()

Will result in:

for user in users[:5]:
    TypeError: 'generator' object has no attribute '__getitem__'

Similarly, trying something like this:

users = session.nearby_users() # returns a list of users nearby
user = users[0]
user.bio # their biography

will result in the same error, since you can't reference a generator like that.

How do I get around this?

@nicshackle
Copy link
Author

Solve: a for loop will implicitly move through a generator if used like this:

users = session.nearby_users() # returns a list of users nearby
for user in users:
    print(user.name)

Although how would one do something like users[n].like()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant