Creating temporary files with tempfile

suggest change

You can create temporary files which have a visible name on the file system, available from the name attribute. delete=True, the default on every platform, removes the file when it is closed. Reopening that name later requires delete=False. Opening the same name while the original file is still open works on Unix and fails on Windows.

The page describes creating a named temporary file, writing ‘Hello World!’ to it, saving name in path, printing that path, closing the file, opening it again, and printing the contents. The sample itself is not on the page. The second open only succeeds when the file was not deleted on close.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents