Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Config Argument Env Parser (CAEP)

Project description


config module, supports loading config from ini, environment and arguments

The configuration presedence are (from lowest to highest):

  • argparse default
  • ini file
  • environment variable
  • command line argument


Arguments are parsed in two phases. First, it will look for the argument --config argument which can be used to specify an alternative location for the ini file. If not --config argument is given it will look for an ini file in the following locations (~/.config has presedence):

  • ~/.config/<CONFIG_ID>/<CONFIG_FILE_NAME> (or directory specified by XDG_CONFIG_HOME)

The ini file can contain a "[DEFAULT]" section that will be used for all configurations. In addition it can have a section that corresponds with <SECTION_NAME> that for specific configuration, that will over override config from DEFAULT

Environment variables

The configuration step will also look for environment variables in uppercase and with "-" replaced with "_". For the example below it will lookup the following environment variables:

  • $BOOL
  • $STR_ARG


>>> import caep
>>> import argparse
>>> parser = argparse.ArgumentParser("test argparse")
>>> parser.add_argument('--number', type=int, default=1)
>>> parser.add_argument('--bool', action='store_true')
>>> parser.add_argument('--str-arg')
>>> args = caep.config.handle_args(parser, <CONFIG_ID>, <CONFIG_FILE_NAME>, <SECTION_NAME>)

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 caep, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size caep-0.0.4.tar.gz (4.5 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