Skip to main content

Parsing and validation of environment variables

Project description

Simple means of parsing and validating environment variables. Heavily inspired by the earlier versions of webargs, which also explains the name to some extend.


$ pip install envargs


from envargs import Var, parse_env

required_vars = {
    'A_INT': Var(
        validate=lambda x: x >= 0,
    'A_LIST': Var(
        use=lambda x: x.split(','),
            lambda x: len(x) == 2,
            lambda x: x[0] == 'first element',
    'A_STR': Var(

parsed = parse_env(required_vars)

Say you want to configure your Flask app using this:


Why reinvent the wheel again?

To be fair there are many good packages out there to parse environment variables, quite a few of them in python too. So this package can easily be seen as redundant. However, with separation of parsing and validation into two separate functions, you gain more power to control what is actually accepted, not to mention that it makes it possible to inline a few more things, as you can most often get away with using builtin functions for most parsing and validation, and when that is not enough, lambdas or partials can do the rest.

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 envargs, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size envargs-0.2.1-py3-none-any.whl (5.7 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size envargs-0.2.1.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page