Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Writeable file object that atomically updates a file.
branch: master
Failed to load latest commit information.
debian Initial debianization.
.gitignore Start to ignore something.
.travis.yml Turn on testing against Python 3.3
LICENSE.rst Add MIT license.
README.rst Version bump to 1.0. Gratipay experiment.
atomicfile.py add docstring for encoding argument
setup.py Version bump to 1.0. Gratipay experiment.
tests.py

README.rst

AtomicFile

https://travis-ci.org/sashka/atomicfile.png?branch=master

Writeable file object that atomically updates a file.

All writes will go to a temporary file. Call close() explicitly when you are done writing, and AtomicFile will rename the temporary copy to the original name, making the changes visible. If the object is destroyed without being closed, all your writes are discarded.

AtomicFile is friendly to with statement.

from atomicfile import AtomicFile

with AtomicFile("panic.txt", "w") as f:
    f.write(json.dumps(big_data_array_100MB, sort_keys=True, indent=4))

Install

To install AtomicFile, simply:

pip install atomicfile
Something went wrong with that request. Please try again.