<div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 19, 2019 at 6:27 AM Antoine Pitrou <<a href="mailto:solipsis@pitrou.net">solipsis@pitrou.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
-1. Please don't remove tempfile.mktemp(). mktemp() is useful to<br>
create a temporary *name*. All other tempfile functions create an<br>
actual file and impose additional burden, for example by making the<br>
file unaccessible by other processes. But sometimes all I want is a<br>
temporary name that an *other* program will create / act on, not Python.<br>
It's a very common use case when writing scripts.<br>
<br>
The only reasonable workaround I can think of is to first create a<br>
temporary directory using mkdtemp(), then use a well-known name inside<br>
that directory. But that has the same security implications AFAICT,<br>
since another process can come and create the file / symlink first.<br></blockquote><div><br></div><div>If all you need is a random name, why not just use a random number generator?</div><div>E.g. I see code like this:</div><div><br></div><div> binascii.hexlify(os.urandom(8)).decode('ascii')<br></div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div></div></div>