[issue5577] yield in iterators

qwjqwj report at bugs.python.org
Fri Mar 27 17:33:28 CET 2009


qwjqwj <qwj at papayamobile.com> added the comment:

More experiments:
The tuple pair (10,20) don't correspond to (i,i*i)
The yield order is distorted

>>> x = (((yield i),(yield i*i)) for i in range(3))
>>> x.__next__()
0
>>> x.send(10)
0
>>> x.send(20)
(10, 20)
>>> x.send(30)
1
>>> x.send(40)
1
>>> x.send(60)
(40, 60)
>>> x.send(70)
2
>>> x.send(80)
4
>>> x.send(90)
(80, 90)
>>> x.send(100)
Traceback (most recent call last):
  File "<pyshell#107>", line 1, in <module>
    x.send(100)
StopIteration

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5577>
_______________________________________


More information about the Python-bugs-list mailing list