temporary

Context managers for managing temporary files and directories.


License
MIT
Install
pip install temporary==3.0.0

Documentation

Temporary Version Build Coverage Health

Compatibility Implementations Format Downloads

Context managers for managing temporary files and directories.

Installation:

$ pip install temporary

Temporary Directory Examples

The temporary directory is created when entering the context manager, and deleted when exiting it:

This time let's make the temporary directory our working directory:

The suffix, prefix, and parent_dir options are passed to the standard tempfile.mkdtemp() function:

This function can also be used as a decorator, with the in_temp_dir alias:

Temporary File Examples

The temporary file is created when entering the context manager and deleted when exiting it.

The user may also supply some content for the file to be populated with:

The temporary file can be placed in a custom directory:

If, for some reason, the user wants to delete the temporary file before exiting the context, that's okay too: