In python you can create a tempfile as follows:
tempfile.TemporaryFile()
And then you can write to it. Where is the file written in a GNU/L
Looking at .name on a file handle is indeed one way to see where the file exists. In the case of TemporaryFile (on *NIX systems), you'll see , indicating an open file handle, but no corresponding directory entry. You'll need to use NamedTemporaryFile if you'd like to preserve the link to the underlying file.
If you wish to control where temporary files go, look at the dir parameter:
TemporaryFile uses mkstemp, which allows setting the directory with the dir parameter:
If
diris specified, the file will be created in that directory; otherwise, a default directory is used. The default directory is chosen from a platform-dependent list, but the user of the application can control the directory location by setting theTMPDIR,TEMPorTMPenvironment variables.