[Python-Dev] PEP 380 (yield from a subgenerator) comments

Nick Coghlan ncoghlan at gmail.com
Wed Mar 25 14:37:49 CET 2009


Nick Coghlan wrote:
> With those two ideas combined, the PEP's "yield from" expansion could
> then look like:
> 
>   for x in EXPR:
>     _v = yield x
>     if _v is not None:
>       continue _v
>   else _r:
>     RESULT = _r

Oops, got a little carried away there. Obviously, that doesn't handle
thrown in exceptions the way "yield from" is intended to.

So even with an adjusted for loop the full semantic expansion of 'yield
from' would still need to be defined directly in terms of try/except and
method calls on the underlying iterator to get the desired exception
handling characteristics.

Cheers,
Nick.

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


More information about the Python-Dev mailing list