Skip to main content

Manage required and optional environment variables in your scripts.

Project description

# pyconfigvar

Manage required and optional environment variables in your Python scripts.

## Example

`sh $ REQUIRED_VAR="something" python `

`python >>> import pyconfigvar >>> pyconfigvar.requiredvar('REQUIRED_VAR') 'something' >>> pyconfigvar.requiredvar('MISSING_VAR') >>> pyconfigvar.requiredvar('MISSING_VAR') MISSING_VAR was not supplied in the environment. <drop back to shell> `

## Usage

There are four functions available:

### requiredvar(var)

Returns the contents of the environment variable var. If var is not present in the environment, sys.exit() is invoked to terminate the interpreter.

### optionalvar(var, default)

Like requiredvar(), but instead of terminating, default is returned.

### requiredbool(var)

Like requiredvar(), but will coerce the value of var into a boolean and return that. Essentially, anything non-zero or non-empty will return True, otherwise it will return False.

### optionalbool(var, default)

Like requiredbool(), but will return default rather than terminate the interpreter.

## Contributing

Pull request away!

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyconfigvar-1.0.0-py3-none-any.whl (3.7 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