Skip to main content

A small extension for the tempfile module.

Project description

A replacement for tempfile.NamedTemporaryFile that does not delete the file on close(), but still unlinks it after the context manager ends.

  • Mostly reuses the stdlib implementation, supporting the same signatures.

  • Due to that, uses the OS’s built-in temporary file facilities, no custom schemes.

  • Tested on Python 2.6+ and 3.3+

Usage

A typical use-case that is not possible with the regular NamedTemporaryFile:

import volatile

with volatile.file() as tmp:
    # tmp behaves like a regular NamedTemporaryFile here, except for that
    # it gets unlinked at the end of the context manager, instead of when
    # close() is called.

    tmp.close()

    # run the users $EDITOR
    run_editor(tmp.name)

    buf = open(tmp.name).read()

    # ...

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

volatile-0.2.tar.gz (1.7 kB view details)

Uploaded Source

File details

Details for the file volatile-0.2.tar.gz.

File metadata

  • Download URL: volatile-0.2.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for volatile-0.2.tar.gz
Algorithm Hash digest
SHA256 257b220f6e09fcdcf57c8593eaee17657c2ef2ac07e986ca3e1a933353be7deb
MD5 4329b7b6821763df85a2ef929444058f
BLAKE2b-256 595543487b6c1032d874b6662247f43c9d0dfe15c221c45aaee71b771d40f240

See more details on using hashes here.

Supported by

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