[Python-ideas] x=(yield from) confusion [was:Yet another alternative name for yield-from]

Jim Jewett jimjjewett at gmail.com
Fri Apr 3 18:42:20 CEST 2009

On 4/3/09, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 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.

err... I didn't mean both directions, I meant "from the callee to the
caller as a yielded value" and "from the callee to the caller as a
final return value that can't be yielded normally."

> But they're still needed,
> because they define the points at which the task
> can be suspended.

If they don't send or receive values, then why do they need to be
expressions instead of statements?

>> 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,

That sounds to me like an implicit loop.

    yield from iter <==>  for val in iter: yield val

So the outside generator won't progress to its own next line (and
subsequent yield) until it has finished looping over the inner


More information about the Python-ideas mailing list