[Python-ideas] with statement: multiple context manager

Christian Heimes lists at cheimes.de
Sun Mar 1 21:57:50 CET 2009


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:
      ...

for two reasons. For one I dislike the temporary variable that is
required for some cases, e.g. the case I used in my initial proposal. It
doesn't feel quite right to use a useless placeholder. The proposed way
follows the example of the import statement, too::

  from module import a, b as x, d as y


Christian




More information about the Python-ideas mailing list