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

If you're not sure about the file name format, learn more about wheel file names.

pyconfigvar-1.0.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file pyconfigvar-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyconfigvar-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43e7b373903ca3e464ca6efaea8eb2131eb26f2a1c4f7254c15e5795c653ed1e
MD5 889848073ec345c60915964f5af32119
BLAKE2b-256 f158680633a8d2f54a28189f24d3bcfaaa234f998c9b922371469c5a5a81ba4d

See more details on using hashes here.

Supported by

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