Python 3 - os.tmpnam() Method


Description

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

Syntax

Following is the syntax for tmpnam() method −

os.tmpnam()

Parameters

NA

Return Value

This method returns a unique path name.

Example

The following example shows the usage of tmpnam() method.

# !/usr/bin/python3
import os, sys

# Temporary file generated in current directory
tmpfn = os.tmpnam()

print "This is the unique path:"
print tmpfn

Result

When we run the above program, it produces the following result −

This is the unique path:
/tmp/fileUFojpd
python_files_io.htm
Advertisements