Make a unique filesystem path, without creating the file

Grant Edwards invalid at invalid.invalid
Mon Feb 15 10:46:47 EST 2016


On 2016-02-14, Ben Finney <ben+python at benfinney.id.au> wrote:
> Howdy all,
>
> How should a program generate a unique filesystem path and *not* create
> the filesystem entry?

Short answer: you can't because it's the filesystem entry operation
that is atomic and guarantees uniqueness.

> [..]

> 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?

What's the point of creating a unique path if you don't want to create
the file?

-- 
Grant Edwards               grant.b.edwards        Yow! I'm rated PG-34!!
                                  at               
                              gmail.com            



More information about the Python-list mailing list