[Python-ideas] yield-from and @coroutine decorator [was:x=(yield from) confusion]

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Apr 4 23:51:21 CEST 2009

Jacob Holm wrote:

>  RESULT = yield from EXPR with STARTEXPR
>  RESULT = yield from EXPR as NAME starting with STARTEXPR(NAME)
> And letting STARTEXPR if given take the place of the initial _i.next() 

No, that's not satisfactory at all, because it introduces
a spurious value into the stream of yielded values seen
by the user of the outer generator.

For refactoring to work correctly, the first value yielded
by the yield-from expression *must* be the first value
yielded by the subgenerator. There's no way of achieving
that when using the Beazley decorator, because it thinks
the first yielded value is of no interest and discards it.

>> We have a long way to go before we even come close to consuming as many
>> pixels as PEP 308 or PEP 343 - a fact for which Greg is probably 
>> grateful ;)

At least Guido will know if someone manages to unsubscribe
him from the list -- he won't be getting 500 messages about
yield-from every day. :-)


More information about the Python-ideas mailing list