[Python-Dev] anonymous blocks (original) (raw)

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:

withfile(filename) as f: dosomethingwith(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' assignmenttarget] ':' 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