allow tuples in a with statement?

Sometimes multiple arguments in a with statement would be convinient. with open('in.txt','rt'), \ open('out.txt','wt'),\ open('err.txt','wt') \ as fstdin, fstdout, fstderr: But today this has to be written as: with open('in.txt','rt') as fstdin: with open('out.txt','wt') as fstdout: with open('err.txt','wt') as fstderr: with the effect of causing multiple redundant levels of intendation. Regards, Sturla Molden

Sturla Molden wrote:
Sometimes multiple arguments in a with statement would be convinient.
with open('in.txt','rt'), \ open('out.txt','wt'),\ open('err.txt','wt') \ as fstdin, fstdout, fstderr:
But today this has to be written as:
with open('in.txt','rt') as fstdin: with open('out.txt','wt') as fstdout: with open('err.txt','wt') as fstderr:
with the effect of causing multiple redundant levels of intendation.
contextlib.nested ? TJG

On Tue, Jan 13, 2009 at 9:07 PM, Sturla Molden <sturla@molden.no> wrote:
Sometimes multiple arguments in a with statement would be convinient.
This has occurred to me as well. In sympy, we have considered using the with statement for assumptions on variables. Tuples would provide a very natural syntax for multiple assumptions: with x>0, y>0: simplify(sqrt((x+y)**2)) Fredrik
participants (3)
-
Fredrik Johansson
-
Sturla Molden
-
Tim Golden