cfgparse -- python configuration file parser module

Dan Gass (

Version 1.2

Download Source and Documentation:

Requires Python 2.3 -or- Python 2.2 and textwrap module from 2.3

cfgparse is a more convenient, flexible, and powerful module for parsing configuration files than the standard library ConfigParser module. cfgparse uses a more declarative style modelled after the popular optparse standard library module.

cfgparse can optionally cooperate with the optparse module to provide coordination between command line and configuration file options. In addition, the cooperation can be used to allow the user to control features of the parser from the command line.

If you like this module and want to see it in the standard Python distribution, please take the time and add your comments to the Python Configuration File Parser Shootout wiki:

Standard Features

Advanced Features

For example:

# file: intro.ini
retries = 10

And script:

# file:
import cfgparse
c = cfgparse.ConfigParser()
c.add_option('retries', type='int')
opts = c.parse()
print 'Number of retries:',opts.retries

Results in:

$ python
Number of retries: 10