Re: iterator idea

2006-10-26 Thread Paul Rubin
Duncan Booth <[EMAIL PROTECTED]> writes: > I wouldn't agree that there is no way reasonable way to get the terminating > value with takewhile, you just need another generator or two: Hmm, I hadn't thought about iterator.send. I'll have to look at that more carefully and re-read the PEP. -- http

Re: iterator idea

2006-10-26 Thread Duncan Booth
Paul Rubin wrote: ... > For example, the annoyance means itertools.takewhile consumes an extra > element with no reasonable way to retrieve it. ... > >def is_even(n): return (n%2 == 0) >def is_odd(n): return (n%2 != 0) > ># we want to do something with all

iterator idea

2006-10-26 Thread Paul Rubin
I wonder if Python would benefit from letting a generator jump to another iterator, i.e. something like yield return *seq would be the equivalent of for s in seq: yield s return except that it would work by transferring control directly to seq's iterator (like a goto) instead of callin