Extremely simple helper for the memory-tempfile package
Project description
pytmpfile
Extremely simple helper for memory-tempfile. Intended to use in non-Python programs requiring files (e.g., GCC).
Usage:
from pytmpfile import get_tmp_path
import os
if __name__ == '__main__':
with get_tmp_path(content='print("hello")\n', suffix='.py') as tmp_path:
print(f'{tmp_path} exists inside context manager: {os.path.exists(tmp_path)}')
print('And it has this content:')
with open(tmp_path, 'r') as f:
print(f.read())
print(f'{tmp_path} exists outside context manager: {os.path.exists(tmp_path)}')
Output:
/run/user/1000/tmpemeg9rhm.py exists inside context manager: True
And it has this content:
print("hello")
/run/user/1000/tmpemeg9rhm.py exists outside context manager: False
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
pytmpfile-0.2.0.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for pytmpfile-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e317ea2d2f5bc1f4e3a0d869a766f2ac50abfa1d3db264dd13ed70ceb5b8716 |
|
MD5 | d4b2ba2e01c1feeb78529977c05db344 |
|
BLAKE2b-256 | dbaeed2c0264c1a46232439c1d345085ff3cd2427ce7e4f9a993a1896cd60e4a |