temp
raw JSON → 2020.7.2 verified Fri May 01 auth: no python
Provides temporary file and directory creation functions (temp.tempdir(), temp.tempfile()). Version 2020.7.2 is the latest release, with irregular cadence. The library is essentially a wrapper around tempfile with a different API.
pip install temp Common errors
error ModuleNotFoundError: No module named 'temp' ↓
cause The package is not installed, or you are trying to import the wrong name.
fix
Run 'pip install temp'.
error AttributeError: module 'temp' has no attribute 'tempfile' ↓
cause The package might be imported incorrectly, or an older version lacks the function.
fix
Use 'from temp import tempfile' and ensure you have version 2020.7.2 or later.
Warnings
gotcha Do not confuse 'temp.tempfile' with the standard library 'tempfile' module. They are different APIs. ↓
fix Use 'from temp import tempfile' instead of 'import tempfile'.
gotcha The package version uses a date-based versioning scheme (year.month.minor). The version 2020.7.2 does not indicate patches or features. ↓
fix Treat version numbers as release dates; check for updates manually.
Imports
- tempfile wrong
import tempfilecorrectfrom temp import tempfile - tempdir
from temp import tempdir
Quickstart
from temp import tempfile, tempdir
# Create a temporary file
with tempfile() as f:
f.write(b'test')
f.seek(0)
print(f.read())
# Create a temporary directory
with tempdir() as d:
print(d)