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.0

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.0
File Size Uploaded
conf-0.2.0.tar.gz 3.6 kB Details

Built distribution (wheel)

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

Total release size: 7.7 kB

Release files / conf-0.2.0.tar.gz

Download URL conf-0.2.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
02cec77d25885011fe74ca109e9660093f2b5a0b1005d5d9ea8121ff897c788d
BLAKE2b-256 checksum
How to use checksums
bdc3f571ce0d08df67bf16fd963e42ea379ed6895652e3b31db5f203035e9854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.1

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

Download URL conf-0.2.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6a42f4a34d9d9a9edf3feee42bda99dceccb054f7f60c631341512901d203e7
BLAKE2b-256 checksum
How to use checksums
481db50f6a473913a201f243e91377e7c7ce155de7bfc55337988a120d1fcc43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.1

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

0.2.1

2 release files

This release

0.2.0 This release

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