Skip to main content

Create and clean up temporary directories

Project description

API

tempdir.create_temp_dir()

Creates a temporary directory and returns an instance of TemporaryDirectory. The directory will be deleted when the instance of TemporaryDirectory is closed.

TemporaryDirectory

Has the following attributes:

  • path - path to the temporary directory

  • close() - delete the temporary directory, including any files and sub-directories

TemporaryDirectory is a context manager, so using with will also delete the temporary directory.

Example

import tempman

with tempman.create_temp_dir() as directory:
    assert os.path.exists(directory.path)
    assert os.path.isdir(directory.path)

assert not os.path.exists(directory.path)

Installation

pip install tempman

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tempman-0.1.0.tar.gz (2.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page