[Python-ideas] with statement: multiple context manager

Guido van Rossum guido at python.org
Thu Mar 26 17:33:45 CET 2009


On Thu, Mar 26, 2009 at 8:42 AM, Sturla Molden <sturla at molden.no> wrote:
> 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?

No, the parens will be syntactically *illegal*.

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



More information about the Python-ideas mailing list