[issue5577] yield in iterators

qwjqwj report at bugs.python.org
Fri Mar 27 17:52:22 CET 2009


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

Ok, I see. Thanks.
However, I don't think yield should be consumed at the iterator's level.
It may be more useful for the outside function to consume the yield.

For example, some function want to change some data with another "thread".

def f():
    ...fetch data...
    x = [yield i for i in data]

It should be written as belowed in Python 3.1 now
def f():
    x = []
    for i in data:
        x.append((yield i))

----------

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


More information about the Python-bugs-list mailing list