tempname.mktemp functionality deprecation

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Apr 30 02:40:20 EDT 2017


Devin Jeanpierre wrote:
> I vote the last one: you can read the .name attribute of the returned
> file(-like) object from NamedTemporaryFile to get a path to a file,
> which can be passed to other functions.

I don't think that helps. You would have to delete the file
first before you could create a link with that name, and that
would leave a window of opportunity for another process to
create something with the same name.

I would generate a name that's likely to be unique (using
mktemp() or otherwise) and try to create a link with that name.
If it fails because the name is in use, generate another name
and try again.

-- 
Greg


More information about the Python-list mailing list