[Python-Dev] Re: anonymous blocks

Jim Fulton jim at zope.com
Wed Apr 27 13:42:07 CEST 2005


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 highlights:
> 
> - temporarily sidestepping the syntax by proposing 'block' instead of 'with'
> - __next__() argument simplified to StopIteration or ContinueIteration instance
> - use "continue EXPR" to pass a value to the generator
> - generator exception handling explained

This looks pretty cool.

Some observations:

1. It looks to me like a bare return or a return with an EXPR3 that happens
    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?

2. I assume it would be a hack to try to use block statements to implement
    something like interfaces or classes, because doing so would require
    significant local-variable manipulation.  I'm guessing that
    either implementing interfaces (or implementing a class statement
    in which the class was created before execution of a suite)
    is not a use case for this PEP.

Jim

-- 
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