tempfile.tempdir

tempfile.tempdir When set to a value other than None, this variable defines the default value for the dir argument to all the functions defined in this module. If tempdir is unset or None at any call to any of the above functions except gettempprefix() it is initialized following the algorithm described in gettempdir().

tempfile.SpooledTemporaryFile()

tempfile.SpooledTemporaryFile(max_size=0, mode='w+b', buffering=None, encoding=None, newline=None, suffix=None, prefix=None, dir=None) This function operates exactly as TemporaryFile() does, except that data is spooled in memory until the file size exceeds max_size, or until the file’s fileno() method is called, at which point the contents are written to disk and operation proceeds as with TemporaryFile(). The resulting file has one additional method, rollover(), which causes the file to rol

tempfile.NamedTemporaryFile()

tempfile.NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix=None, prefix=None, dir=None, delete=True) This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name attribute of the returned file-like object. Whether the name can be used to open the file a second time, while the named temporary file is s

tempfile.mktemp()

tempfile.mktemp(suffix='', prefix='tmp', dir=None) Deprecated since version 2.3: Use mkstemp() instead. Return an absolute pathname of a file that did not exist at the time the call is made. The prefix, suffix, and dir arguments are similar to those of mkstemp(), except that bytes file names, suffix=None and prefix=None are not supported. Warning Use of this function may introduce a security hole in your program. By the time you get around to doing anything with the file name it returns,

tempfile.mkstemp()

tempfile.mkstemp(suffix=None, prefix=None, dir=None, text=False) Creates a temporary file in the most secure manner possible. There are no race conditions in the file’s creation, assuming that the platform properly implements the os.O_EXCL flag for os.open(). The file is readable and writable only by the creating user ID. If the platform uses permission bits to indicate whether a file is executable, the file is executable by no one. The file descriptor is not inherited by child processes. Un

tempfile.mkdtemp()

tempfile.mkdtemp(suffix=None, prefix=None, dir=None) Creates a temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable, and searchable only by the creating user ID. The user of mkdtemp() is responsible for deleting the temporary directory and its contents when done with it. The prefix, suffix, and dir arguments are the same as for mkstemp(). mkdtemp() returns the absolute pathname of the new directo

tempfile.gettempprefixb()

tempfile.gettempprefixb() Same as gettempprefix() but the return value is in bytes. New in version 3.5.

tempfile.gettempprefix()

tempfile.gettempprefix() Return the filename prefix used to create temporary files. This does not contain the directory component.

tempfile.gettempdirb()

tempfile.gettempdirb() Same as gettempdir() but the return value is in bytes. New in version 3.5.

tempfile.gettempdir()

tempfile.gettempdir() Return the name of the directory used for temporary files. This defines the default value for the dir argument to all functions in this module. Python searches a standard list of directories to find one which the calling user can create files in. The list is: The directory named by the TMPDIR environment variable. The directory named by the TEMP environment variable. The directory named by the TMP environment variable. A platform-specific location:On Windows, the direct