Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Make a unique filesystem path, without creating the file Date: Mon, 15 Feb 2016 21:11:01 +1300 Lines: 26 Message-ID: References: <85r3gf55k4.fsf@benfinney.id.au> <56c14ed7$0$11089$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net CBPy+w/pnIPvxcDAy88ARQsFmvWCbPAHQBU5A7pD4YobY1OzKr Cancel-Lock: sha1:GOp72VXgcy6Om3FqhuU73ODPYX8= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:102949 Ben Finney wrote: > The existing behaviour of ‘tempfile.mktemp’ – actually of its internal > class ‘tempfile._RandomNameSequence’ – is to generate unpredictable, > unique, valid filesystem paths that are different each time. But that's not documented behaviour, so even if mktemp() weren't marked as deprecated, you'd still be relying on undocumented and potentially changeable behaviour. > What I'm > looking for is a way to use it (not re-implement it) that is public API > and isn't scolded by the library documentation. Then you're looking for something that doesn't exist, I'm sorry to say, and it's unlikely you'll persuade anyone to make it exist. If you want to leverage stdlib functionality for this, I'd suggest something along the lines of: def fakefilename(dir, ext): return os.path.join(dir, str(uuid.uuid4())) + ext -- Greg