1

Running this gives me the error TypeError: 'Status' object is not iterable

I'm trying to get the statuses from the user.

import simplejson
import httplib2
import tweepy
import random
import time
import itertools

def paginate(iterable, page_size):
    while True:
        i1, i2 = itertools.tee(iterable)
        iterable, page = (itertools.islice(i1, page_size, None),
                list(itertools.islice(i2, page_size)))
        if len(page) == 0:
            break
        yield page

auth = tweepy.OAuthHandler("removed", "removed")
auth.set_access_token("removed", "removed")

api = tweepy.API(auth)

timeline = api.user_timeline("removed")

for res in paginate(timeline, 50):
    for twet in res[1]:
        print(twet.id)
2
  • 1
    what is the full text of the error? Commented Nov 16, 2014 at 5:27
  • Traceback (most recent call last): File "fav.py", line 25, in <module> for twet in res[1]: TypeError: 'Status' object is not iterable Commented Nov 16, 2014 at 5:35

1 Answer 1

1

Looks like a pretty simple fix: Just remove the [1] part, and you should get the ID for each tweet.

for res in paginate(timeline, 50):
    for twet in res:
        print(twet.id)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.