[Python-Dev] Remove tempfile.mktemp()
Guido van Rossum
guido at python.org
Tue Mar 19 10:52:12 EDT 2019
On Tue, Mar 19, 2019 at 6:27 AM Antoine Pitrou <solipsis at pitrou.net> wrote:
> -1. Please don't remove tempfile.mktemp(). mktemp() is useful to
> create a temporary *name*. All other tempfile functions create an
> actual file and impose additional burden, for example by making the
> file unaccessible by other processes. But sometimes all I want is a
> temporary name that an *other* program will create / act on, not Python.
> It's a very common use case when writing scripts.
> The only reasonable workaround I can think of is to first create a
> temporary directory using mkdtemp(), then use a well-known name inside
> that directory. But that has the same security implications AFAICT,
> since another process can come and create the file / symlink first.
If all you need is a random name, why not just use a random number
E.g. I see code like this:
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev