<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:49F751FB.9040102@wanadoo.fr" type="cite">spir a
écrit :
  <blockquote cite="mid:20090428110425.1eea5299@o" type="cite">
    <pre wrap="">Le Mon, 27 Apr 2009 20:54:58 +0100,
Arnaud Delobelle <a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
 href="mailto:arnodel@googlemail.com"><arnodel@googlemail.com></a> s'exprima ainsi:

  </pre>
    <blockquote type="cite">
      <blockquote type="cite">
        <pre wrap="">with A(), B() as a,b:
   # Code that uses a and b.

This would translate directly to:

with A() as a:
   with B() as b:
       # Code that uses a and b.  
      </pre>
      </blockquote>
      <pre wrap="">There was a discussion about this on this list:

<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://mail.python.org/pipermail/python-ideas/2009-March/003188.html">http://mail.python.org/pipermail/python-ideas/2009-March/003188.html</a>

I can't remember the outcome.
    </pre>
    </blockquote>
    <pre wrap=""><!---->
There was no clear outcome, for sure ;-)

Except maybe it was stated that 
   with A(), B() as a,b:
should rather be spelled
   with A() as a, B() as b:
to reuse the syntax of imports.

Denis

------
la vita e estrany
_______________________________________________
Python-ideas mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:Python-ideas@python.org">Python-ideas@python.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://mail.python.org/mailman/listinfo/python-ideas">http://mail.python.org/mailman/listinfo/python-ideas</a>


    </pre>
  </blockquote>
</blockquote>
I agree with the idea of auto-nesting "with", however in the case you
pointed out, the main problem was the early evaluation of context
managers ; <br>
maybe a solution would be to delay the creation of context managers,
with something like a partial application (cf functools).<br>
<br>
Roughly, we'd need a "delayedNested" function, which takes
zero-argument callables as parameters, and calls/instanciates them
inside itself.<br>
<br>
Then just call<b> delayedNested(partial(A,...arguments...), partial(B,
...arguments...))</b><i> </i>to have what you want.<br>
<br>
Yes I know, it's not pretty (mainly because of the lack of partial
application syntax in python), but it's just a placeholder ^^<br>
<br>
Regards, <br>
Pascal
</body>
</html>