You are here : python_2osostmpfile

os.tmpfile() - os

             

The method tmpfile() returns a new temporary file object opened in update mode (w+b). The file has no directory entries associated with it and will be deleted automatically once there are no file descriptors.


  • NA


Syntax


os.tmpfile


Example


# !/usr/bin/python

import os

# The file has no directory entries associated with it and will be
# deleted automatically once there are no file descriptors.
tmpfile = os.tmpfile()
tmpfile.write('Temporary newfile is here.....')
tmpfile.seek(0)

print tmpfile.read()
tmpfile.close


Output / Return Value

When we run above program, it produces following result:


Temporary newfile is here.....


Limitations


Alternatives / See Also


Reference