lambda generator - curious behavior in 2.5

Boris Borcic bborcic at gmail.com
Sat Apr 21 05:21:00 EDT 2007


 >>> 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
 >>> x.next()
888
 >>> x.next()

Traceback (most recent call last):
   File "<pyshell#29>", line 1, in <module>
     x.next()
StopIteration
 >>>



More information about the Python-list mailing list