with statement for two files

Diez B. Roggisch deets at nospam.web.de
Mon Jul 28 19:02:35 CEST 2008

Paul Rubin wrote:

> braver <deliverable at gmail.com> writes:
>> with open(src) as readin, open(dst,"w") as writin:   # WRONG: comma
>> doesn't work
>>   ...
>> -- so that you have transactional safety for two file descriptors?
> use contextlib.nexted().

You mean contextlib.nested I guess. Didn't know about that module, cool!

However, the fundamental problem stays: rolling back only works if the
innermost context fails.


More information about the Python-list mailing list