[Python-ideas] with statement: multiple context manager

Chris Rebert pyideas at rebertia.com
Sun Mar 1 22:35:07 CET 2009


On Sun, Mar 1, 2009 at 12:57 PM, Christian Heimes <lists at cheimes.de> wrote:
> Chris Rebert wrote:
>> While I still mostly like the idea, it does seem to undermine Python's
>> uniformity a bit.
>
> I played with both possible versions before I wrote the proposal. Both
> ways have their pros and cons. I'm preferring the proposed way::
>
>  with a, b as x, d as y:
>       ...
>
> over the other possibility::
>
>  with a, b, c as _, x, y:
>      ...

You misunderstand me. My quibble isn't over the exact syntax (in fact,
I completely agree about the superiority of the proposed ordering),
but rather that we're introducing syntax to do something that can
already be done with a function (nested()) and is /extremely/ similar
to another case (parallel for-loop) where we are opting to still
require the use of a function (zip()). This proposed asymmetry
concerns me.

> The proposed way
> follows the example of the import statement, too::
>
>  from module import a, b as x, d as y

This parallel does quell my concern somewhat.

Cheers,
Chris

--
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-ideas mailing list