[Python-Dev] Ext4 data loss
greg.ewing at canterbury.ac.nz
Sun Mar 15 23:25:04 CET 2009
Nick Coghlan wrote:
> It actually wouldn't be a bad place to put a "create a temporary file
> and rename it to <name> when closing it" helper class.
I'm not sure it would be a good idea to make that
behaviour automatic on closing. If anything goes
wrong while writing the file, you *don't* want the
rename to happen, otherwise it defeats the purpose.
It would be okay to have an explicit close_and_rename()
method, although there wouldn't be much gained over
just calling os.rename() afterwards.
What might make more sense is a context manager,
with renaming_file("blarg.txt", "w") as f:
More information about the Python-Dev