[Python-Dev] PEP 380 (yield from a subgenerator) comments
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Mar 27 11:54:03 CET 2009
Steve Holden wrote:
> I am a *bit* concerned, without really being able to put my finger on
> it, that the "yield from" expression's value comes from inside (the
> "return" from the nested generator) while the "yield from" expression's
> value comes from "outside" (the value passed to a .send() method call).
The send() calls don't go to the yield-from expression, they
go to the yields inside the subgenerator. Similarly, next()
calls get their values from the yields inside the subgenerator.
The only time the yield-from expression itself receives a
value is right at the very end when the subgenerator
terminates, and that's not a yielding operation, it's a
returning operation.
Yield-from is not a kind of yield. It's a kind of function
call.
--
Greg
More information about the Python-Dev
mailing list