[Python-ideas] Yield-From: GeneratorReturn exception

Nick Coghlan ncoghlan at gmail.com
Sun Mar 29 03:00:24 CEST 2009


Greg Ewing wrote:
> While attempting to update the PEP to incorporate a
> GeneratorReturn exception, I've thought of a potential
> difficulty in making the exception type depend on
> whether the return statement had a value.
> 
> Currently the StopIteration exception is created after
> the return statement has unwound the stack frame, by
> which time we've lost track of whether it had an
> expression.

Does it become easier if "return None" raises StopIteration instead of
raising GeneratorReturn(None)?

I think I'd prefer that to having to perform major surgery on the eval
loop to make it do something else... (Guido may have other ideas,
obviously).

Cheers,
Nick.

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



More information about the Python-ideas mailing list