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

Discussion in 'Python' started by John Nagle, Nov 11, 2010.

  1. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Nov 11, 2010
    #1
    1. Advertising

  2. John Nagle

    Guest

    On Nov 11, 11:32 am, John Nagle <> wrote:
    >    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.
     
    , Nov 11, 2010
    #2
    1. Advertising

  3. John Nagle

    Carl Banks Guest

    On Nov 11, 10:32 am, John Nagle <> wrote:
    >    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
     
    Carl Banks, Nov 12, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oliver Knoll

    reading file created with tmpfile?

    Oliver Knoll, Jul 18, 2003, in forum: C Programming
    Replies:
    4
    Views:
    451
    Chris Torek
    Jul 18, 2003
  2. Replies:
    7
    Views:
    406
    Karthik Gurusamy
    Dec 28, 2007
  3. Brad
    Replies:
    0
    Views:
    299
  4. Replies:
    2
    Views:
    355
  5. Alex van der Spek

    Difference between tempfile and spooled tempfile?

    Alex van der Spek, Apr 5, 2012, in forum: Python
    Replies:
    2
    Views:
    369
    Steve Howell
    Apr 5, 2012
Loading...

Share This Page