tempname.mktemp functionality deprecation

Cameron Simpson cs at zip.com.au
Tue May 2 19:00:29 EDT 2017


On 01May2017 14:31, Tim Chase <python.list at tim.thechases.com> wrote:
>On 2017-05-01 18:40, Gregory Ewing wrote:
>> The following function should be immune to race conditions
>> and doesn't use mktemp. [loop trying names until os.link does not fail die 
>> to an existing name]
>
>Ah, this is a good alternative and solves the problem at hand.
>
>As a side-note, apparently os.rename() is only atomic on *nix
>systems, but not on Windows.  For the time being, I'm okay with that.

Just to your point about my (bogus) suggestion with NamedTemporaryFile, only 
alternative is a temporary directory, then making a file inside that. But 
Gregory Ewing's suggestion is much more direct.

Cheers,
Cameron Simpson <cs at zip.com.au>



More information about the Python-list mailing list