Skip to main content

Konf is a Python package which designed to simplify a process of variables usage in configuration files. json and yaml supported out of the box.

Project description


Designed to simplify a process of variables usage in configuration files. Importing variables to Python must be easy!


pip install konf


  • Easy to use

  • JSON and YAML support out of the box

  • Require typing or validation of all input data for human factor prevention

  • Python 2.7, 3+ compatible

  • Unit-tested

  • Custom format of configuration files can be used

For Python data structures validation used excellent lib kolypto/py-good

For YAML parsing used great lib of Kirill Simonov PyYAML

How to use this library

It’s pretty simple. Just look at the code.

from konf import Konf

k_ = Konf('fruits.yml')
APPLE = k_('APPLE', basestring)
ORANGE = k_('ORANGE', basestring)
BASKET_OF_MANDARINS = k_('BASKET', [basestring])
NAMED_BANANAS = k_('BANANAS', {'yellow': basestring, 'banana2': basestring})

k2_ = Konf('grades.json')
DAVID_GRADE = k2_('DAVID', int)
MARIA_GRADE = k2_('MARIA', int)

You can find more details and advanced examples about natural validation on documentation of the “good” validation library

List of supporting Exceptions after abnormal situations


Raises when data from config file doesn’t match to the type_or_validator arg


Raises after trying to get variable that not contained in config file


Raises when config file can’t be read


Raises if third-party parser can’t parse configuration file


Raises if variable is loading from Konf not for the first time


Raises if extension of the config is not .yml or .json, and parse_callback arg is not specified

That’s it!

Pull-requests are welcome.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

konf-1.0.tar.gz (3.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page