Make a unique filesystem path, without creating the file
Ben Finney
ben+python at benfinney.id.au
Sun Feb 14 19:08:52 EST 2016
Matt Wheeler <m at funkyhat.org> writes:
> On 14 Feb 2016 21:46, "Ben Finney" <ben+python at benfinney.id.au> 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
More information about the Python-list
mailing list