Version 0.3.7 of the config module has been released

Vinay Sajip vinay_sajip at
Fri Oct 5 13:15:57 CEST 2007

Version 0.3.7 of the Python config module has been released.

What Does It Do?
The config module allows you to implement a hierarchical configuration
scheme with support for mappings and sequences, cross-references
between one part of the configuration and another, the ability to
flexibly access real Python objects, facilities for configurations to
include and cross-reference one another, simple expression evaluation
and the ability to change, save, cascade and merge configurations. You
can easily integrate with command line options using optparse.

This module has been developed on python 2.3 but should work on
version 2.2 or greater. A test suite using unittest is included in the

A very simple configuration file (simple.cfg):

# starts here
message: Hello, world!
#ends here

a very simple program to use it:

from config import Config

cfg = Config(file('simple.cfg'))
print cfg.message

results in:

Hello, world!

Configuration files are key-value pairs, but the values can be
containers that contain further values.

A simple example - with the example configuration file:

    stream : `sys.stderr`
    message: 'Welcome'
    name: 'Harry'
    stream : `sys.stdout`
    message: 'Welkom'
    name: 'Ruud'
    stream : $messages[0].stream
    message: 'Bienvenue'
    name: Yves

a program to read the configuration would be:

from config import Config

f = file('simple.cfg')
cfg = Config(f)
for m in cfg.messages:
    s = '%s, %s' % (m.message,
        print >>, s
    except IOError, e:
        print e

which, when run, would yield the console output:

Welcome, Harry
Welkom, Ruud
Bienvenue, Yves

The above example just scratches the surface. There's more information
about this module available at

Comprehensive API documentation is available at

As always, your feedback is most welcome (especially bug reports,
patches and suggestions for improvement). Enjoy!


Vinay Sajip
Red Dove Consultants Ltd.

Changes since the last release posted on comp.lang.python[.announce]:
Added Mapping.__delitem__ (patch by John Drummond).
Mapping.__getattribute__ no longer returns "" when asked
for "__class__" - doing so causes pickle to crash
(reported by Jamila Gunawardena).
Allow negative numbers (reported by Gary Schoep; had
already been fixed but not yet released).

More information about the Python-announce-list mailing list