[Python-Dev] Coroutines, generators, function calling

Andrew Koenig ark at acm.org
Fri Oct 21 06:58:28 CEST 2005


> so the new syntax would
> not be useful, unless it was something that provided access to the index
> item as a variable, like:
> 
> yield foo(i) for i in x
> 
> which barely saves you anything (a colon, a newline, and an indent).

Not even that, because you can omit the newline and indent:

	for i in x: yield foo(i)

There's a bigger difference between

	for i in x: yield i

and

	yield from x

Moreover, I can imagine optimization opportunities for "yield from" that
would not make sense in the context of comprehensions.





More information about the Python-Dev mailing list