yield_all needed in Python

Douglas Alan nessus at mit.edu
Wed Mar 2 20:40:52 CET 2005

Nick Coghlan <ncoghlan at iinet.net.au> writes:

> If you do write a PEP, try to get genexp syntax supported by the
> yield keyword.

> That is, the following currently triggers a syntax error:
>    def f():
>      yield x for x in gen1(arg)


   yield *(x for x in gen1(arg))

be sufficient, and would already be supported by the proposal at

Also, with the syntax you suggest, it's not automatically clear
whether you want to yield the generator created by the generator
expression or the values yielded by the expression.  The "*" makes
this much more explicit, if you ask me, without hindering readability.


More information about the Python-list mailing list