The Python Way for module configuration?

Ben Finney ben+python at
Sun Jun 28 05:28:31 CEST 2009

(Even if you don't want to receive email, could you please give your
actual name in the ‘From’ field instead of just initials? It makes
conversation less confusing.)

kj < at> writes:

> But, minimally, the module needs to have some configuration details to
> know where to get the data. There are many ways to provide this
> configuration data to the module, but I would like to know what's
> considered "best practice" for this type of problem in the Python
> world.
> Ideally, I'm looking for a system that is unobtrusive under normal
> operations, but easy to override during testing and debugging.

The standard library provides the ability to parse plain text
configuration files and populate a collection of values for
configuration. The module's name is changing to conform to the library
standards; see <URL:>.

This way, you can customise the execution of your program by modifying
configuration settings in a non-executable configuration file. It also
allows a cascade of overrides, for e.g. user-specific configuration
overrides or test-specific overrides, etc.

 \          “It is well to remember that the entire universe, with one |
  `\   trifling exception, is composed of others.” —John Andrew Holmes |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list