[Python-ideas] with statement: multiple context manager

Sturla Molden sturla at molden.no
Thu Mar 26 16:42:02 CET 2009


On 3/26/2009 4:07 PM, Mathias Panzenböck wrote:

> Good point. Maybe that would be better:
> 
>    with a,b as c,d:

No. See Guido's reply.

I was just trying to say that

   with nested(a,b) as c,d:

is more readble than

   with a as c, b as d:

which would argue against new syntax and better documentation of 
contextlib.nested. However, as the tuple (a,b) is built prior to the 
call to nested, new syntax is needed.

It still does not hurt to put in parentheses for readability here:

   with (a as c), (b as d):


Perhaps parentheses should be recommended in the documentation, even 
though they are syntactically superfluous here?


Sturla Molden














More information about the Python-ideas mailing list