Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Hierarchical YAML configuration utility for Python

Project description


Hierarchical YAML configuration utility for Python

yamlcfg makes it easier to have different levels of YAML configuration files,
with prioritization that you declare, based on the order of the `paths`
keyword argument.

It first checks your environment for the variable, and if it exists, it uses
that over anything else. Then it checks the first file in `paths`, or `path`,
and then the next in order until the variable is found. If not found, it returns

Access is allowed via normal attribute access via the dot operator, or from
an index such as `config['myattr']`.

To dump the full configuration that was loaded back to file (first path in
`paths`), just invoke `write()`.


from yamlcfg import YamlConfig
config = YamlConfig(path='~/.some_config.yml')
print( = 'bar'

fifo_configs = YamlConfig(paths=
('.myconfig.yml', '~/.userconfig.yml', '/etc/myconfig/defaultconfig.yml')
# First checks .myconfig.yml, and if it doesn't exist there, it checks
# ~/.userconfig.yml, and so on. If an environment variable of the same name
# is set, it will use that first.
# Dumps to the first path in paths, with every variable it found in order.

Project details

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
yamlcfg-0.5.3.tar.gz (5.2 kB) Copy SHA256 hash SHA256 Source None

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 SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page