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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Apr 7 00:37:23 CEST 2009


Jacob Holm wrote:

> No, in the coroutine pattern it absolutely should not. The first value 
> yielded by the generator of every coroutine is None and should be thrown 
> away.

That only applies to the *top level* of a coroutine. If
you factor some code out of a coroutine and call it using
yield-from, the first value yielded by the factored-out
code is needed and mustn't be thrown away.

So I stand by what I said before. If you're using such
a decorator, you only apply it to the top level generator
of the coroutine, and you don't call the top level
using yield-from.

-- 
Greg





More information about the Python-ideas mailing list