On Nov 12, 12:09 pm, rusi <[email protected]> wrote:
> This is a classic problem -- structure clash of parallel loops
<rest snipped>
Sorry wrong solution :D
The fidgetiness is entirely due to python not allowing C-style loops
like these:
>> while ((c=getchar()!= EOF) { ... }
Putting it into coroutine form, it becomes something like the
following [Untested since I dont have the API]. Clearly the
fidgetiness is there as before and now with extra coroutine plumbing
def genStage(term, target):
page = 1
while 1:
r = api.GetSearch(term="foo", page=page)
if not r: break
for tweet in r: target.send(tweet)
page += 1
@consumer
def endStage():
while True: process((yield))
if __name__ == '__main__':
genStage("foo", endStage())
--
http://mail.python.org/mailman/listinfo/python-list