The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
On 11Nov2012 08:56, Stefan Behnel <stefan...@behnel.de> wrote:
| Steve Howell, 11.11.2012 04:03:
| > On Nov 10, 2:58 pm, Roy Smith <r...@panix.com> wrote:
| >> page = 1
| >> while 1:
| >> r = api.GetSearch(term="foo", page=page)
| >> if not r:
| >> break
| >> for tweet in r:
| >> process(tweet)
| >> page += 1
| >> It works, but it seems excessively fidgety. Is there some cleaner way
| >> to refactor this?
| > I think your code is perfectly readable and clean, but you can flatten
| > it like so:
| > def get_tweets(term, get_page):
| > page_nums = itertools.count(1)
| > pages = itertools.imap(api.getSearch, page_nums)
| > valid_pages = itertools.takewhile(bool, pages)
| > tweets = itertools.chain.from_iterable(valid_pages)
| > return tweets
| I'd prefer the original code ten times over this inaccessible beast.
In an insane society, the sane man must appear insane.
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.