Re: lambda generator - curious behavior in 2.5

2007-04-21 Thread Raymond Hettinger
[Gabriel Genellina] > This time, the ((tuple) and None) is like saying "discard the tuple and > return None instead", and that fires the usual StopIteration. It looks like the offending code is in the gen_send_ex() function in Objects/genobject.c: if (result == Py_None && f->f_stacktop

Re: lambda generator - curious behavior in 2.5

2007-04-21 Thread Gabriel Genellina
En Sat, 21 Apr 2007 06:21:00 -0300, Boris Borcic <[EMAIL PROTECTED]> escribió: > >>> x = (lambda : ((yield 666),(yield 777),(yield 888)))() > >>> x.next() > 666 > >>> x.next() > 777 > >>> x.next() > 888 > >>> x.next() > (None, None, None) I think nobody thought in advance this case (a lamb

Re: lambda generator - curious behavior in 2.5

2007-04-21 Thread James Stroud
Boris Borcic wrote: > >>> x = (lambda : ((yield 666),(yield 777),(yield 888)))() > >>> x.next() > 666 > >>> x.next() > 777 > >>> x.next() > 888 > >>> x.next() > (None, None, None) > >>> x = (lambda : ((yield 666),(yield 777),(yield 888)) and None)() > >>> x.next() > 666 > >>> x.next() > 777