permanent tempfile?

skip at pobox.com skip at pobox.com
Mon Aug 21 10:26:49 EDT 2006


    Colin> I am trying to create a temp file, however the file that is
    Colin> created is still there after the program has completed.  Why is
    Colin> this so?

After you call os.remove(filename) it's still there?  My version of your
script works for me:

    import tempfile, os

    filename = tempfile.mkstemp()[1]
    print filename

    # test it ...
    fout = open(filename, 'w')
    fout.write("just a text file")
    fout.close()
    os.remove(filename)
    print os.path.exists(filename)

Running it I get this output:

    /tmp/tmp6CUDA-
    False

Maybe the semantics on Windows are different.

Skip



More information about the Python-list mailing list