Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

betterconfig -- A Better Config for Python

Project Description

betterconfig provides a more convenient and extensible configuration language, and a simpler interface built on python’s builtin ConfigParser format, along with a drastically simplified interface for loading configs.

Type Coercion Boilerplate Sucks

ConfigParser, like many config languages, treats all values as strings, meaning that when you have configs like this:

foo = 1
bar = a,list,of,strings
baz = just a plain old string

you end up with boilerplate that looks like this:

from ConfigParser import ConfigParser
MAP = {
    'foo': int,
    'bar': lambda x: x.split(','),
    'baz': str,
c = ConfigParser()'./foo.cfg')
config = {k:MAP[k](v) for k,v in c.items('config')}

Don’t you really wish you could just do this:

foo = 1
bar = ['a', 'list', 'of', 'strings']
baz = "just a plain old string"

and drop the map?

import betterconfig
config = betterconfig.load('./foo.cfg')['config']

betterconfig supports all literal types supported by ast.literal_eval: strings, numbers, tuples, lists, dicts, booleans, and None.

More Flexibility in Config, Less Config by Module

We wanted a config language that was as easy to use as a settings module in django or flask (and nearly as extensible), but less magical to initialize, and slightly safer than something like this:

import importlib
settings = importlib.import_module('settings')

So we want a config that can do stuff like this:

top_level  = 'variables defined outside of sections'
include    = ['./include.cfg', 'include.d/*.cfg']

namespaced = True

And we don’t want to have to iterate sections or items, we really just want to load it into a dict:

import betterconfig
settings = betterconfig.load('./fancy.cfg')

And if you’re really in love with . notation, you can always do something silly like make a module that does something magical like:

import betterconfig


The betterconfig project lives on github, and is available via pip.

Installing v0.3 From Pip

sudo pip install betterconfig==0.3

Installing v0.3 From Source

curl | tar vzxf -
cd betterconfig
sudo python install

Running Tests

The betterconfig tests require py.test, which can be installed via pip.

sudo pip install pytest==2.5.2

Authors and Contributors

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
betterconfig-0.3.tar.gz (5.9 kB) Copy SHA256 Checksum SHA256 Source Apr 22, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting