21 Apr
2005
21 Apr
'05
4:52 p.m.
[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/)