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.

Meta

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

Metadata

Release files for conf 0.2.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.2.1
File Size Uploaded
conf-0.2.1.tar.gz 3.6 kB Details

Built distribution (wheel)

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

Total release size: 8.6 kB

Release files / conf-0.2.1.tar.gz

Download URL conf-0.2.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
05030843835c110066723477be23379e8b2600e88691589868232a162a118ee6
BLAKE2b-256 checksum
How to use checksums
5ddd2881374aaec25023b986c397ed6a251693baceb7cade4c306276a0883bd2
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.2.1-py3-none-any.whl

Download URL conf-0.2.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
486362db3d0d1c53cf95d01f8e288c76167571eeef827911984bc86f9b622159
BLAKE2b-256 checksum
How to use checksums
9a9298687fdc8c2694459dbe8d7611121e9d4bb1453fe88bec60974cb32441bd
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

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.1 This release

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