os.tmpfile() vs. tempfile.TemporaryFile()

J

John Nagle

Is there any reason to prefer "tempfile.TemporaryFile()"
over "os.tmpfile()"? Both create a nameless temporary file
that will be deleted on close.

John Nagle
 
D

danmcleran

   Is there any reason to prefer "tempfile.TemporaryFile()"
over "os.tmpfile()"?  Both create a nameless temporary file
that will be deleted on close.

                                John Nagle

tempfile.TemporaryFile has more options, e.g. file prefix, suffix, dir
location, mode, and buf size. if you don't care about any of that,
then it probably makes no difference.
 
C

Carl Banks

   Is there any reason to prefer "tempfile.TemporaryFile()"
over "os.tmpfile()"?  Both create a nameless temporary file
that will be deleted on close.

os.tmpfile calls your OS's tmpfile system call.
tempfile.TemporaryFile creates the temporary file itself.

So, if you trust your OS more than Python, use os.tempfile.


I-only-use-tempfile-module-ly yr's,

Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top