27 Mar
2009
27 Mar
'09
4:24 p.m.
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