tempfile.mkdtemp()
tempfile.mkdtemp() is a Python function in the Tempfile Module category. Creates a temporary directory that persists after creation. The syntax is tempfile.mkdtemp(suffix=None, prefix=None, dir=None). Parameters: suffix, prefix, dir. Returns: Path string. A typical example: import os, tempfile
d = tempfile.mkdtemp()
print(d) # "/tmp/tmpXXXXXX/"
# Caller must delete: os.rmdir(d). A close sibling is tempfile.TemporaryFile(), which creates a temporary file that is automatically deleted when closed. A close sibling is tempfile.NamedTemporaryFile(), which creates a temporary file with a visible name in the filesystem. A close sibling is tempfile.mkstemp(), which creates a temporary file and returns a (fd, path) tuple. Caller must close and delete. A close sibling is tempfile.TemporaryDirectory(), which creates a temporary directory that is automatically cleaned up when closed. More about this category: Temporary file and directory creation — TemporaryFile, mkstemp, mkdtemp. Related Tempfile Module entries: tempfile.TemporaryFile(), tempfile.NamedTemporaryFile(), tempfile.mkstemp(), tempfile.TemporaryDirectory(), tempfile.gettempdir(), tempfile.tempdir.