Skip to main content

Remove tempory files at program exit, combination of tempfile and atexit should be as simple as possible.

Project description

tempfileatexit

Python library for removing temporary files and directories when program finishes.

Installation

pip install tempfileatexit

Usage

Automatic way

import tempfileatexit as tfae
(fs, my_tempfile) = tfae.mkstemp()
my_tempdir = tfae.mkdtemp()

print(tempfileatexit.list(verbose=True))

Manual way

import tempfileatexit
import tempfile

(fs, my_tempfile) = tempfile.mkstemp()
my_tempdir = tempfile.mkdtemp()

tempfileatexit.register(my_tempfile)
tempfileatexit.register(my_tempdir)


print(tempfileatexit.list(verbose=True))

After you run the code and the program exxists, the my_tempfile and my_tempdir will be gone.

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

tempfileatexit-0.0.3.tar.gz (2.1 kB view hashes)

Uploaded Source

Built Distribution

tempfileatexit-0.0.3-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

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