Re: A gnarly little python loop

2012-11-12 Thread rusi
On Nov 12, 9:09 pm, Steve Howell wrote: > On Nov 12, 7:21 am, rusi wrote: > > > On Nov 12, 12:09 pm, rusi wrote:> This is a classic > > problem -- structure clash of parallel loops > > > > > > Sorry wrong solution :D > > > The fidgetiness is entirely due to python not allowing C-style loops >

Re: A gnarly little python loop

2012-11-12 Thread Steve Howell
On Nov 12, 7:21 am, rusi wrote: > On Nov 12, 12:09 pm, rusi wrote:> This is a classic > problem -- structure clash of parallel loops > > > > Sorry wrong solution :D > > The fidgetiness is entirely due to python not allowing C-style loops > like these: > > >> while ((c=getchar()!= EOF) { ... } >

Re: A gnarly little python loop

2012-11-12 Thread Peter Otten
rusi wrote: > The fidgetiness is entirely due to python not allowing C-style loops > like these: > >>> while ((c=getchar()!= EOF) { ... } for c in iter(getchar, EOF): ... > Clearly the fidgetiness is there as before and now with extra coroutine > plumbing Hmm, very funny... -- http://mai

Re: A gnarly little python loop

2012-11-12 Thread rusi
On Nov 12, 12:09 pm, rusi wrote: > This is a classic problem -- structure clash of parallel loops 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

Re: A gnarly little python loop

2012-11-11 Thread rusi
On Nov 11, 3:58 am, Roy Smith wrote: > I'm trying to pull down tweets with one of the many twitter APIs.  The > particular one I'm using (python-twitter), has a call: > > data = api.GetSearch(term="foo", page=page) > > The way it works, you start with page=1.  It returns a list of tweets. > If the

Re: A gnarly little python loop

2012-11-11 Thread Steve Howell
On Nov 11, 4:44 pm, Cameron Simpson wrote: > On 11Nov2012 11:16, Steve Howell wrote: > | On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote: > | > Steve Howell wrote: > | > > On Nov 11, 1:09 am, Paul Rubin wrote: > | > >> Cameron Simpson writes: > | > >> > | I'd prefer the original code

Re: A gnarly little python loop

2012-11-11 Thread Cameron Simpson
On 11Nov2012 11:16, Steve Howell wrote: | On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote: | > Steve Howell wrote: | > > On Nov 11, 1:09 am, Paul Rubin wrote: | > >> Cameron Simpson writes: | > >> > | I'd prefer the original code ten times over this inaccessible beast. | > >> > Me too.

Re: A gnarly little python loop

2012-11-11 Thread Roy Smith
In article , Peter Otten <__pete...@web.de> wrote: > deque( > imap( > process, > chain.from_iterable( > takewhile(bool, imap(partial(api.GetSearch, term), count(1), > maxlen=0) > > ;) If I wanted STL, I would still be writing C++ :-) -- http://mail.pyth

Re: A gnarly little python loop

2012-11-11 Thread Steve Howell
On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote: > Steve Howell wrote: > > On Nov 11, 1:09 am, Paul Rubin wrote: > >> Cameron Simpson writes: > >> > | I'd prefer the original code ten times over this inaccessible beast. > >> > Me too. > > >> Me, I like the itertools version better.  The

Re: A gnarly little python loop

2012-11-11 Thread Peter Otten
Steve Howell wrote: > On Nov 11, 1:09 am, Paul Rubin wrote: >> Cameron Simpson writes: >> > | I'd prefer the original code ten times over this inaccessible beast. >> > Me too. >> >> Me, I like the itertools version better. There's one chunk of data >> that goes through a succession of transform

Re: A gnarly little python loop

2012-11-11 Thread Steve Howell
On Nov 11, 1:09 am, Paul Rubin wrote: > Cameron Simpson writes: > > | I'd prefer the original code ten times over this inaccessible beast. > > Me too. > > Me, I like the itertools version better.  There's one chunk of data > that goes through a succession of transforms each of which > is very str

Re: A gnarly little python loop

2012-11-11 Thread Steve Howell
On Sunday, November 11, 2012 1:54:46 AM UTC-8, Peter Otten wrote: > Paul Rubin wrote: > > > > > Cameron Simpson writes: > > >> | I'd prefer the original code ten times over this inaccessible beast. > > >> Me too. > > > > > > Me, I like the itertools version better. There's one chunk of da

Re: A gnarly little python loop

2012-11-11 Thread Peter Otten
Paul Rubin wrote: > Cameron Simpson writes: >> | I'd prefer the original code ten times over this inaccessible beast. >> Me too. > > Me, I like the itertools version better. There's one chunk of data > that goes through a succession of transforms each of which > is very straightforward. [Steve

Re: A gnarly little python loop

2012-11-11 Thread Paul Rubin
Cameron Simpson writes: > | I'd prefer the original code ten times over this inaccessible beast. > Me too. Me, I like the itertools version better. There's one chunk of data that goes through a succession of transforms each of which is very straightforward. -- http://mail.python.org/mailman/lis

Re: A gnarly little python loop

2012-11-11 Thread Cameron Simpson
On 11Nov2012 08:56, Stefan Behnel wrote: | Steve Howell, 11.11.2012 04:03: | > On Nov 10, 2:58 pm, Roy Smith wrote: | >> page = 1 | >> while 1: | >> r = api.GetSearch(term="foo", page=page) | >> if not r: | >> break | >> for tweet in r: | >>

Re: A gnarly little python loop

2012-11-11 Thread Stefan Behnel
Steve Howell, 11.11.2012 04:03: > On Nov 10, 2:58 pm, Roy Smith wrote: >> I'm trying to pull down tweets with one of the many twitter APIs. The >> particular one I'm using (python-twitter), has a call: >> >> data = api.GetSearch(term="foo", page=page) >> >> The way it works, you start with page=1

Re: A gnarly little python loop

2012-11-10 Thread Steve Howell
On Nov 10, 2:58 pm, Roy Smith wrote: > I'm trying to pull down tweets with one of the many twitter APIs.  The > particular one I'm using (python-twitter), has a call: > > data = api.GetSearch(term="foo", page=page) > > The way it works, you start with page=1.  It returns a list of tweets. > If the

Re: A gnarly little python loop

2012-11-10 Thread Steven D'Aprano
On Sat, 10 Nov 2012 17:58:14 -0500, Roy Smith wrote: > The way it works, you start with page=1. It returns a list of tweets. > If the list is empty, there are no more tweets. If the list is not > empty, you can try to get more tweets by asking for page=2, page=3, etc. > I've got: > > page =

Re: A gnarly little python loop

2012-11-10 Thread Ian Kelly
On Sat, Nov 10, 2012 at 3:58 PM, Roy Smith wrote: > I'm trying to pull down tweets with one of the many twitter APIs. The > particular one I'm using (python-twitter), has a call: > > data = api.GetSearch(term="foo", page=page) > > The way it works, you start with page=1. It returns a list of twe

A gnarly little python loop

2012-11-10 Thread Roy Smith
I'm trying to pull down tweets with one of the many twitter APIs. The particular one I'm using (python-twitter), has a call: data = api.GetSearch(term="foo", page=page) The way it works, you start with page=1. It returns a list of tweets. If the list is empty, there are no more tweets. If t