I want to use tempfile
module, to generate files and keep them in /tmp/myfolder/
and keep them there until a certain time (maybe in days). I learned that tempfile
removes file as soon as f.close()
is run. I just don't want it to auto-remove. Will remove later. Is this possible with tempfile
? or any other better approach?
You can use this:
import tempfile
with tempfile.NamedTemporaryFile(delete=False, dir='/tmp/myfolder') as outfile:
# ...