YouTip LogoYouTip

Os Tempnam

# Python2.x Python os.tempnam() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The `os.tempnam()` method is used to return a unique pathname for creating a temporary file. ### Syntax The syntax for the **tempnam()** method is as follows: os.tempnam(dir, prefix) ### Parameters * **dir** -- The path where the temporary file is to be created. * **prefix** -- The prefix for the temporary file. ### Return Value This method returns a unique path. ### Example The following example demonstrates the use of the `tempnam()` method: ## Example #!/usr/bin/python # -*- coding: UTF-8 -*- import os,sys # File with prefix '' tmpfn =os.tempnam('/tmp/','') print"This is a unique path:" print tmpfn The output of executing the above program is: This is a unique path:/tmp//tutorialIbAco8 [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Django Cookie SessionDjango Form Component β†’