wim
wim

Reputation: 363566

Python tool to generate a unique temporary filename

To get a unique name for a temporary file you can use NamedTemporaryFile. But I want a fifo instead of a regular file, so something like:

name = generate_unique_name()  # how?
try:
    os.mkfifo(name)
    # do stuff with the FIFO
finally:
    os.remove(name)

Is there a stdlib way to autogenerate a temporary filename which is guaranteed to be unique in a directory?

Upvotes: 1

Views: 1605

Answers (1)

icktoofay
icktoofay

Reputation: 129139

Python has the tempfile module, which may have what you're looking for in it.

Upvotes: 11

Related Questions