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

Support iteration with manually called next() #20

Merged
merged 2 commits into from
Sep 27, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions TwitterSearch/TwitterSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, consumer_key, consumer_secret, access_token, access_token_sec
# init internal variables
self.__response = {}
self.__nextMaxID = maxint
self._nextTweet = 0

if "proxy" in attr:
self.setProxy(attr["proxy"])
Expand Down Expand Up @@ -172,8 +173,6 @@ def setSupportedLanguages(self, order):

# Iteration
def __iter__(self):
if not self.__response:
raise TwitterSearchException(1014)
self._nextTweet = 0
return self

Expand All @@ -182,6 +181,9 @@ def next(self):
return self.__next__()

def __next__(self):
if not self.__response:
raise TwitterSearchException(1014)

if self._nextTweet < len(self.__response['content']['statuses']):
self._nextTweet += 1
return self.__response['content']['statuses'][self._nextTweet-1]
Expand Down