You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
title='option to leave tempfile.NamedTemporaryFile around on close'updated_at=<Date2007-03-13.18:32:06.000>user='https://bugs.python.org/djmdjm'
tempfile.NamedTemporaryFile provides a good interface
to creating temporary files, but its insistence on
deleting the file upon close is limiting. The attached
patch adds an optional parameter to NamedTemporaryFile
that allows persistence of the temp file after it has
One use-case that demonstrates where keeping the
temporary file around is handy would be when you need
to safely create and fill a temp file before it is
atomically moved into place with os.rename(). E.g.
Right, it doesn't create a filesystem file. But that is the
point. You work in memory and then write to your final
destination as needed. Your code you have pasted in the
description does nothing special that requires the use of a
temporary file. You can just write into a StringIO object,
skip the os.link call, and then just write out to the final