Skip to main content

Try to import all modules below a given root

Project description

Safely write or print to a file, leaving it unchanged if something goes wrong.

Example:

import safer

with safer.writer(filename) as fp:
    for line in source():
       fp.write('this and that')

with safer.printer(filename) as print:
    print('this', 'and', 'that')
    print('two', 'lines', sep='\n')
    # ...

Writes occur on a temporary file, which is only copied over the original file when the block completes successfully, so safer will temporarily use as much disk space as the old file and the new file put together.

This is great for writing any files which you don’t want to get partially overwritten if something goes wrong in the writing process.

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

safer-0.9.4.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

safer-0.9.4-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

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