[Python-Dev] Re: anonymous blocks

Jim Fulton jim at zope.com
Wed Apr 27 15:44:03 CEST 2005

Duncan Booth wrote:
> Jim Fulton <jim at zope.com> wrote in news:426F7A8F.8090109 at zope.com:
>>Guido van Rossum wrote:
>>>I've written a PEP about this topic. It's PEP 340: Anonymous Block
>>>Statements (http://python.org/peps/pep-0340.html).
>>Some observations:
>>1. It looks to me like a bare return or a return with an EXPR3 that
>>    to evaluate to None inside a block simply exits the block, rather
>>    than exiting a surrounding function. Did I miss something, or is
>>    this a bug?
> No, the return sets a flag and raises StopIteration which should make the 
> iterator also raise StopIteration at which point the real return happens.

Only if exc is not None

The only return in the pseudocode is inside "if exc is not None".
Is there another return that's not shown? ;)

I agree that we leave the block, but it doesn't look like we
leave the surrounding scope.


Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org

More information about the Python-Dev mailing list