Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Read environment variables defined in a shell script into Python.

Project description


Read environment variables defined in a shell script into Python.
This library uses the shell to get variable values, and handles multiline variables.


Given a shell file: myvars.env:

export VAR1=1
export VAR2="This
multiline value"
export VAR3=3


>>> import shellvars
>>> shellvars.get_vars('myvars.env')
{'VAR1': '1', 'VAR2': 'This\nis\na\nmultiline value', 'VAR3': '3' }


Lists the variable names in the script.

>>> import shellvars
>>> shellvars.list_vars('myvars.env')
['VAR1', 'VAR2', 'VAR3']

This is equivalent to, but faster than

>>> shellvars.get_vars('myvars.env').keys()

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cmdvars, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size cmdvars-0.1.3-py2.py3-none-any.whl (5.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size cmdvars-0.1.3.tar.gz (19.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page