how to get the lastest user status using tweepy
python, tweepy, twitter
Solution
`.items()` returns an iterator, so you can simply call `next()` to get the first item:
status = next(tweepy.Cursor(api.user_timeline).items())
This could raise a `StopIteration` exception if there are no items at all. You could add a default to `next()` to prevent that:
status = next(tweepy.Cursor(api.user_timeline).items(), None)
Problem
I am trying to use tweepy to get the most recent user status My code is ``` api = tweepy.API(auth) for status in tweepy.Cursor(api.user_timeline).items(): lastid = status.id laststatus = api.get_status(lastid).text break ``` it works. But I have to use a loop. Is there any better way?