[Python-ideas] allow tuples in a with statement?

Sturla Molden sturla at molden.no
Tue Jan 13 21:07:05 CET 2009


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






More information about the Python-ideas mailing list