Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Make a unique filesystem path, without creating the file Date: Mon, 15 Feb 2016 11:08:52 +1100 Lines: 25 Message-ID: References: <85r3gf55k4.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de wy7vN4KHwSYuRg6jZpMUBgJWQYJ8hlSBS0a18rYV89Jg== Cancel-Lock: sha1:pzy+NjXfHpaDoiV27BQYGgyXNCg= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'float': 0.05; '*not*': 0.07; 'subject:file': 0.07; 'filesystem': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '2016': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'directory.': 0.18; 'library': 0.20; 'name;': 0.22; 'feb': 0.23; 'consistent': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; 'this.': 0.28; 'path,': 0.29; 'entry': 0.31; 'morning': 0.32; 'file': 0.34; 'could': 0.35; 'exist': 0.35; 'should': 0.36; 'there': 0.36; 'depends': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'future': 0.60; 'ever': 0.60; 'avoid': 0.61; 'real': 0.62; 'within': 0.64; 'our': 0.64; 'goal': 0.64; 'believe': 0.66; 'guaranteed': 0.67; '_o__)': 0.84; 'received:125': 0.84; 'touching': 0.84; 'dust': 0.91; 'subject:Make': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102925 Matt Wheeler writes: > On 14 Feb 2016 21:46, "Ben Finney" wrote: > > What standard library function should I be using to generate > > ‘tempfile.mktemp’-like unique paths, and *not* ever create a real > > file by that path? > > Could you use tempfile.TemporaryDirectory and then just use a > consistent name within that directory. That fails because it touches the filesystem. I want to avoid using a real file or a real directory. > It's guaranteed not to exist I am unconcerned with whether there is a real filesystem entry of that name; the goal entails having no filesystem activity for this. I want a valid unique filesystem path, without touching the filesystem. -- \ “I believe our future depends powerfully on how well we | `\ understand this cosmos, in which we float like a mote of dust | _o__) in the morning sky.” —Carl Sagan, _Cosmos_, 1980 | Ben Finney