contextlib.nested
supports this:
import contextlib
with contextlib.nested(open("out.txt","wt"), open("in.txt")) as (file_out, file_in):
...
Update:
To quote the documentation, regarding contextlib.nested
:
Deprecated since version 2.7: The with-statement now supports this functionality directly (without the confusing error prone quirks).
See Rafal Dowgird's answer for more information.