[Python-Dev] PEP 340 - possible new name for block-statement

Neil Schemenauer nas at arctrix.com
Fri Apr 29 04:35:39 CEST 2005

On Thu, Apr 28, 2005 at 03:55:03PM -0700, Guido van Rossum wrote:
> A variation on this with somewhat different semantics swaps the keywords:
>     in EXPR for VAR:
>         BLOCK

Looks weird to my eyes.

On a related note, I was thinking about the extra cleanup 'block'
provides.  If the 'file' object would provide a suitable iterator,
you could write:

    block open(filename) as line:

and have the file closed at the end of the block.  It does not read
so well though.  In a way, it seems to make more sense if 'block'
called iter() on the expression and 'for' did not.  block would
guarantee to cleanup iterators that it created.  'for' does not but
implictly creates them.


More information about the Python-Dev mailing list