using NamedTemporaryFile on windows

Lee Harr lee at example.com
Thu Dec 29 17:20:47 EST 2005


On 2005-12-29, Peter Hansen <peter at engcorp.com> wrote:
> Lee Harr wrote:
>> Is there any other reason to use a named tempfile other than
>> to be able to open it again?

> As it says, if you *don't close* the file, you can open it again if you 
> are on a platform which supports that.
>

Ok. I just started wondering if maybe there was some other reason,
like stat()ing the file, or taking a picture of Elvis pointing at
it in a directory listing or something.


> NamedTemporaryFile doesn't appear to have much purpose on Windows, but 
> that's more or less what the docs already say.  I think the only thing 
> you were missing perhaps was this idea of "opening a file a second time" 
> *without having closed it first*.
>
> What I don't understand is why you _can't_ reopen the NamedTemporaryFile 
> under Windows when you can reopen the file created by mkstemp (and the 
> files created by TemporaryFile are created by mkstemp in the first place).
>


Are you saying you tried it and you actually can do what it says
you can't do?

I don't have any windows system to test this, but I want to write
some code that will work on windows. I'm just going to use mkstemp.

Thanks for your time.



More information about the Python-list mailing list