Skip to main content

PyPI version Build Status

conf

A very simple and lightweight configuration loader and parser for Python.

Supports:

  • yaml files (*.yml, *.yaml)

  • ini files (*.ini)

  • json files (*.json)

Installation

pip install conf

Usage

Starting your app

Start your app with your configuration file:

python your_app.py --config your_config.yml

Or:

python your_app.py --config config_env_var

The --config argument can be:

  • a relative path to a file;

  • an absolute path to a file;

  • the name of an environment variable which value holds one of the above.

You are allowed to provide multiple configuration names (separated by a single space), in which case any setting of a former configuration file can be overwritten by a setting of a later configuration file (if the name of that setting is identical).

Once you have supplied your application with some configuration, you can fetch the settings of that configuration. There are three options of how to do that.

Fetching your setting (option 1)

Simply get your setting from the conf module:

import conf
your_setting = conf.your_setting

Fetching your setting (option 2)

Import your setting directly:

from conf import your_setting

Fetching your setting (option 3)

You can provide a default value if you are not sure the setting will be present:

import conf
your_setting = conf.get('your_setting', 'your default value')

Note: If you use an ArgumentParser in your own application for other purposes, you must use the parse_known_args() method of the parser.

Fetching your setting (option 4)

You can get the configuration as a dictionary and get your setting as you would get any value from a dict:

import conf
conf_dict = conf.asdict()
your_setting = conf_dict.get('your_setting', 'your default value')

Meta

This lib was designed and written in 2018 by finetuned89 and ramonhagenaars.

Metadata

Release files for conf 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conf 0.3.1
File Size Uploaded
conf-0.3.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conf 0.3.1
File Interpreter ABI Platform
conf-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / conf-0.3.1.tar.gz

Download URL conf-0.3.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a826a9efea4dca5059e3bb01aa85d5e284bec3d16edd4ecad0d6c9e4c4095414
BLAKE2b-256 checksum
How to use checksums
305243b8c396d519b58d93d7ebd515d8726c1d53141a116e3de4c57acc2855d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release files / conf-0.3.1-py3-none-any.whl

Download URL conf-0.3.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f29dcb02571edc1708d2e5dbe0541b3ee9fa989629e4193212ed62a5730349c
BLAKE2b-256 checksum
How to use checksums
485eae10cd1c3d48a240d8b7974c775020467cddd74b98dcc8bae2853cc0392e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release history Release notifications | RSS feed

0.4.1

1 release file

0.4.0

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page