[Python-Dev] anonymous blocks

Guido van Rossum gvanrossum at gmail.com
Thu Apr 21 16:52:35 CEST 2005

[Greg Ewing]
> My current thought is that it should look like this:
>    with_file(filename) as f:
>      do_something_with(f)
> The success of this hinges on how many use cases can
> be arranged so that the word 'as' makes sense in that
> position.
> This way, the syntax is just
>    expr ['as' assignment_target] ':' suite
> and the expr is evaluated quite normally.

Perhaps it could be even simpler: 

    [assignment_target '=']* expr ':' suite

This would just be an extension of the regular assignment statement.

(More in a longer post I'm composing off-line while picking cherries
off the thread.)

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list