with statement for two files

Diez B. Roggisch deets at nospam.web.de
Mon Jul 28 13:02:35 EDT 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.

Diez



More information about the Python-list mailing list