tempfile

The standard library module for creating temporary files and folders that are cleaned up automatically.

In more detail

tempfile.TemporaryDirectory() used in a with statement gives a scratch folder that disappears afterwards, which is handy in tests. Temporary files are created somewhere safe that other programs will not collide with.

Related terms

Taught in

References