Skip to main content

Python environment toolchain

Project description

Useful environment toolchain for python


Context Processor that overrides environment vars.

>>> @override_environment(DEBUG=False, FOO="Bar")
>>> def foo():
>>>     print(os.getenv("FOO"))
>>>     return os.getenv("DEBUG")
>>> foo()
>>> with override_environment(DEBUG="False", FOO="Bar"):
>>>     print(os.getenv("FOO"))
>>>     os.getenv("DEBUG")


Wrap a configDict inside configure_logging, then logging level could be controlled by environment variables

LOGGING = configure_logging({
    "loggers": {
        "module": {
            "handlers": ["console"],
            "level": "INFO",

For this example, environment variable must be set as LOGGING_LEVEL_module=DEBUG.


Similar to os.getenv() but evaluates string content (default) into simple python types.

>>> os.environ['FOO'] = "1"
>>> os.getenv('FOO')
>>> get_env('FOO')

>>> os.environ['FOO'] = "bar"
>>> get_env('FOO')

>>> os.environ['FOO'] = "True"
>>> os.getenv('FOO')
>>> get_env('FOO')

>>> os.environ['FOO'] = "[1,2,3]"
>>> os.getenv('FOO')
>>> get_env('FOO')
[1, 2, 3]

it works for list, tuples, dictionaries, numbers, booleans and strings. And is safe!

Project details

Release history Release notifications

This version
History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
python-envtools-0.0.1rc1.tar.gz (5.5 kB) Copy SHA256 hash SHA256 Source None Dec 7, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page