https://github.com/luispedro/safeout
Simple atomic writing for Python
https://github.com/luispedro/safeout
python
Last synced: 9 months ago
JSON representation
Simple atomic writing for Python
- Host: GitHub
- URL: https://github.com/luispedro/safeout
- Owner: luispedro
- Created: 2016-04-17T06:30:56.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-20T00:56:50.000Z (about 6 years ago)
- Last Synced: 2025-06-12T20:06:21.299Z (about 1 year ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
Awesome Lists containing this project
README
# Safeout: write out a file safely
With `safeout`, you can write:
from safeout import safeout
with safeout('output.txt') as output:
output.write("Hello world\n")
and this will write out the file `output.txt` in a safe, atomic manner. That
is, if there are any problems (Exceptions or a crash) in the `with` block, then
there there will be **no output**. If the `with` block completes, then the
output file will include the whole result.
So, if the output file exists, you can be confident that the process completed
correctly.
License: MIT