ID EN
Tempfile

TemporaryDirectory

Python 3.11

This class securely creates a temporary directory using the same rules as mkdtemp(). The resulting object can be used as a context manager (see Examples). On completion of the context or destruction of the temporary directory object, the newly created temporary directory and all its contents are removed from the filesystem.

Syntax

PYTHON
class tempfile.TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False)

See Also

mkdtemp() context manager Examples context manager with PermissionError auditing event