[Python-ideas] with statement: multiple context manager
Guido van Rossum
guido at python.org
Sun Mar 1 23:01:47 CET 2009
On Sun, Mar 1, 2009 at 1:15 PM, Calvin Spealman <ironfroggy at gmail.com> wrote:
> On Sun, Mar 1, 2009 at 4:01 PM, Gregory P. Smith <greg at krypto.org> wrote:
>> Alternatively if closer conformity with for loop syntax is desirable
>> consider this:
>> with lock, open(infile), open(outfile) as lock, fin, fout:
> We don't have multi-assignment statements in favor of the unpacking
> concept, and I think it carries over here. Also, as mentioned, this
> goes along with the lack of any multi-for statement. The `x as y` part
> of the with statement is basically an assignment with extras, and the
> original suggestion then combines multiple assignments on one line.
> This option, I think, is more concise and readable.
-1 for this variant. The syntactic model is import: import foo as bar,
bletch, quuz as frobl. If we're doing this it should be like this.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas