[Python-Dev] multi-with statement

Georg Brandl g.brandl at gmx.net
Sat May 2 21:01:28 CEST 2009


Hi,

this is just a short notice that Mattias Brändström and I have finished a
patch to implement the previously discussed and mostly warmly welcomed
extension to with's syntax, allowing

   with A() as a, B() as b:

to be written instead of

   with A() as a:
       with B() as b:

This syntax was chosen (over "with A(), B() as a, b:") because it has more
syntactical similarity to the written-out version.  Also, our current uses
of "as" all have only one expression on the right.

The patch implements it as a simple AST transformation, which guarantees
semantic equivalence.  It is at <http://codereview.appspot.com/53094>.

If there is no strong opposition, I will commit it and port it to py3k
before 3.1 enters beta stage.

cheers,
Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-Dev mailing list