[Python-Dev] yield back-and-forth?
Morel Xavier
xavier.morel at masklinn.net
Fri Jan 20 20:14:22 CET 2006
Christian Tanzer wrote:
> How about:
>
> def main_generator():
> ...
> yield * sub_generator()
>
> Ducking-ly yrs,
>
I like that one, but I'd stick the star to the generator (e.g. yield
*sub_generator), the meaning being to "unpack" the generator into the
yield, same as unpacking a sequence passed as function parameters.
As an extension, the syntax may even (though I'm not sure it'd be a good
idea to do so) work with any iterable, behaving the same way (yielding
the successive values of the iterable object)
More information about the Python-Dev
mailing list