Skip to main content

Read and write .netrc files.

Project description

pypi badge travis-ci status

Read and write .netrc files in Python.

tinynetrc uses the netrc module from the standard library under the hood and adds a few improvements:

  • Adds write functionality.

  • Fixes a std lib bug with formatting a .netrc file.*

  • Parses .netrc into dictionary values rather than tuples.

*This bug is fixed in newer versions of Python.

Get it now

pip install tinynetrc

tinynetrc supports Python >= 2.7 or >= 3.5.


from tinynetrc import Netrc

netrc = Netrc()  # parse ~/.netrc
# Get credentials

# Modify an existing entry
netrc['']['password'] = 'newpassword'  # writes to ~/.netrc

# Add a new entry
netrc[''] = {
    'login': '',
    'password': 'secret'

# Removing an new entry
del netrc['']

You can also use Netrc as a context manager, which will automatically save ~/.netrc.

from tinynetrc import Netrc
with Netrc() as netrc:
    netrc['']['password'] = 'newpassword'
    assert netrc.is_dirty is True
# saved!


MIT licensed. See the bundled LICENSE file for more details.

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

tinynetrc-1.3.1.tar.gz (5.5 kB view hashes)

Uploaded source

Built Distribution

tinynetrc-1.3.1-py2.py3-none-any.whl (3.9 kB view hashes)

Uploaded py2 py3

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