[Python-ideas] A real limitation of contextlib.nested()

Ron Adam rrr at ronadam.com
Sun Mar 15 13:58:57 CET 2009



Nick Coghlan wrote:

> Dedicated syntax (such as the form that Christian proposed) would fix
> this problem:
> 
>   with lock, (open(infile) as fin), (open(outfile, 'w') as fout):
>       fout.write(fin.read())

Could 'and' possibly be used sense it is a flow control operator in python.

    with lock
           and open(infile) as fin
           and open(outfile, 'w' as fout:
       fout.write(fin.read())

Ron




More information about the Python-ideas mailing list