On 2013-09-02, Roy Smith <r...@panix.com> wrote: > In article <mailman.508.1378143885.19984.python-l...@python.org>, > "albert visser" <albert.vis...@gmail.com> wrote: > >> I like being able to do e.g. >> >> with open('some_file') as _in, open('another_file', 'w') as _out: > > It would be nice if you could write that as: > > with open('some_file'), open('another_file, 'w') as _in, _out:
3.2 and above provide contextlib.ExitStack, which I just now learned about. with contextlib.ExitStack() as stack: _in = stack.enter_context(open('some_file')) _out = stack.enter_context(open('another_file', 'w')) It ain't beautiful, but it unfolds the nesting and gets rid of the with statement's line-wrap problems. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list