You are here : python_2osostempnam

os.tempnam() - os

             

The method tempnam() returns a unique path name that is reasonable for creating a temporary file.


  • dir -- This is the dir where the temporary filename will be created.

  • prefix -- This is the prefix of the generated temporary filename.


Syntax


os.tempnam(dir, prefix)


Example


# !/usr/bin/python

import os, sys

# prefix is tuts1 of the generated file
tmpfn = os.tempnam('/tmp/tutorialsdir,'tuts1')

print "This is the unique path:"
print tmpfn


Output / Return Value

When we run above program, it produces following result:


This is the unique path: /tmp/tutorialsdir/tuts1IbAco8


Limitations


Alternatives / See Also


Reference