[Python-ideas] x=(yield from) confusion [was:Yet another alternative name for yield-from]
greg.ewing at canterbury.ac.nz
Fri Apr 3 09:23:54 CEST 2009
Jim Jewett wrote:
> yield from *as an expression* only really makes sense if the generator
> is sending useful information *both* ways.
No, that's not the only way it makes sense. In my
multitasking example, none of the yields send or
receive any values. But they're still needed,
because they define the points at which the task
can be suspended.
> The times I did remember that (even) the expression form looped,
The yield-from expression itself doesn't loop. What
it does do is yield multiple times, if the generator
being called yields multiple times. But it has to
be driven by whatever is calling the whole thing
making a sufficient number of next() or send() calls,
in a loop or otherwise.
In hindsight, the wording in the PEP about the
subiterator being "run to exhaustion" might be a bit
misleading. I'l see if I can find a better way to
More information about the Python-ideas