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

Nick Coghlan ncoghlan at gmail.com
Sat Apr 4 03:47:08 CEST 2009

Greg Ewing wrote:
> Nick Coghlan wrote:
>> "return finally" reads pretty well and doesn't add a new keyword
> Still doesn't mean anything, though. Ordinary returns
> happen "finally" too (most of the time, anyway), so
> what's the difference?

It needs to be mnemonic, not literal. The difference between a generator
return and a normal function return is that with a generator you will
typically have at least one yield before the actual return, whereas with
a normal function, return or an exception are the only way to leave the
function's frame. So "return finally" is meant to help you remember that
it happens only after all the yields are done.

Guido has said he is OK with losing the novice assistance on this one
though, so it's probably a moot point.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list