[Python-ideas] Revised^4 PEP on yield-from

Greg Falcon veloso at verylowsodium.com
Thu Feb 19 17:16:01 CET 2009


On Thu, Feb 19, 2009 at 5:12 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>    * ``return expr`` in a generator is equivalent to ``raise
>       StopIteration(expr)``.

It seems to me equivalence here might not be what you want.

This parallel does not exist today between "return" and "raise
StopIteration()", where the former can't be intercepted and blocked by
a try/except block, but the latter can.  I think it would be confusing
for a return statement to be swallowed by code intended as an error
handler.

Greg F



More information about the Python-ideas mailing list