tempfile Question

John Machin sjmachin at lexicon.net
Wed Jun 7 17:30:12 EDT 2006


On 8/06/2006 2:57 AM, Dennis Lee Bieber wrote:
> On Wed, 07 Jun 2006 21:53:02 +1000, John Machin <sjmachin at lexicon.net>
> declaimed the following in comp.lang.python:
> 
>> I passed over mkstemp() because (according to my reading of the manual), 
>> mkstemp() requires an *extra* step (close the file), leaving the 
>> situation then *exactly* the same as with mktemp() i.e. some pirate 
>> process may molest the file before the caller's child process can open 
>> the file.
>>
> 	mktemp() creates ONLY the file name, but not the file itself. This
> means another process calling mktemp() has the possibility of generating
> the SAME file name before the first opens/creates the named file.
> 

Thanks, Dennis. You are quite correct. I'm a dill: I read """Return an 
absolute pathname of a file that did not exist at the time the call is 
made""" as implying that the file existed after the call, brushed aside 
my brief wonderment about what was deprecable about all that, and didn't 
even try it at the interactive prompt.

Cheers,
John



More information about the Python-list mailing list