Temporary files and dirs ======================== The `tempfile library `_ contains the utilities to deal with temporary files and directories. Use the high level interface, because you do not need to worry about cleaning the temporary files. **Possible**:: directory = tempfile.mkdtemp() ... shutil.rmtree(directory) **Better**:: directory = tempfile.TemporaryDirectory() ... **Best**:: with tempfile.TemporaryDirectory() as tmpdirname: ...