Skip to main content

A wrapper of python-configuration

Project description

Python Configuration Wrapper

This lib is basically a wrapper of the python-configuration.

It aims at making configuration easy !


Read multi-level configuration values from multiple sources (precedency ordered):

  1. Command line arguments given by --additional-config or -C parameter.


    python -C "database.dialect=postgresql" --additional-config "" -C "database.user=admin"
  2. Environment variables starting with prefix set in the CONFIG_PREFIX environment variable. Level separator is __ (double underscore).


    CONFIG_PREFIX=TEST TEST__database__user=root python
  3. Config directories given by --config-path or -P parameter. The value of this parameter must be a directory path in which the sub-directories are multi-level keys, and plain-text files content are values. It's very practical when using secrets in containers.


    mkdir /var/run/secrets/database -p
    echo -n 123456 > /var/run/secrets/database/password
    python --config-path /var/run/secrets
  4. Config files given by --config-file or -F parameter. File formats must be among those handled by python-configuration:

    • json
    • ini
    • yaml
    • toml
    • python


    python -F config.json --config-file config.yaml


pip install python-configuration-wrapper


# import the config object from the module
# you can do this in every python file you want
from python_configuration_wrapper import config

# get some value from a multi-level key
myvalue = config.myfirstlevel.mysecondlevel.mykey


See test

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 python-configuration-wrapper, version 1.0.7
Filename, size File type Python version Upload date Hashes
Filename, size python_configuration_wrapper-1.0.7-py3-none-any.whl (3.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size python-configuration-wrapper-1.0.7.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

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