I use Tweepy to collect twitter user informations. I basically want to print some fields using a loop for, avoiding
Here is my code :
fields = ["id", "screen_name", "ceated_at"] # We create a list of 3 fields
user = api.get_user("twitter") # We collect all available informations of the user called 'twitter'
for f in fields : # For our 3 fields, we want the associate information
print f + " : " + user.f
I obtain :
Traceback (most recent call last):
File "test v1.2.py", line 16, in <module>
print f + " : " + user.f
AttributeError: 'User' object has no attribute 'f'
The expected result :
id : 783214
screen_name : twitter
created_at : 2007-02-20 14:35:54
Why 'user.f' doesn't work (last line) whereas 'user.id', 'user.screen_name' and 'user.created_at' work well outside the loop ?
I'm sure this is an evidence for all of you but, for a beginner like me, it's a complete mystery ! :)
Thanks a lot in advance for your explainations,