with statement for two files

braver deliverable at gmail.com
Sun Jul 27 17:23:04 EDT 2008


Can open two files in a with statement:

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?
The comma syntax doesn't work, but is there a way, except for

with open(src) as readin:
  with open(dst,"w) as writin:
    ...

Cheers,
Alexy



More information about the Python-list mailing list