ConfigParser shootout, preliminary entry

Michael Chermside mcherm at mcherm.com
Mon Oct 18 00:13:01 CEST 2004


A few weeks ago, the suggestion was made on Python-Dev that it might be time
to consider replacing the ConfigParser module and that we should hold a
"shootout" (ie ask for implementations and see what we get).

Since then I've been playing around with this... not the parsing part (which
so far I have completely ignored) but the programmer interface. There needs
to be a well-thought-out data model for the information stored, and the user
interface needs to be very easy to use, yet not so "magical" that it becomes
difficult to understand.

I have put together what I think is probably my best proposal. It is based
on a superset of ini config files and java .property files. There is a
convenient access mechanism ("config.my_app.some_value") as well as more
general approaches ("config.values['my_app.serviceByPort.80']"). I have
tried to consider issues like unicode (I permit fairly lenient mixing of
unicode and str), and unit testing ("... call config.clear_all() in the
tearDown() method of any unittests that use the config module..."). I have
even considered carefully what to leave OUT (converting to non-string data
types, interpolating values, things like that).

I think that I am now at the point where I could really use some input from
others. So I'd like to invite people to review my design and send me your
suggestions. I'm not expecting this as a *useful* module yet (it doesn't
yet parse files!), but it seemed like a good stage at which to ask for
feedback. I'm attaching two files, config.py and configTest.py, and they
are also available from these urls:

    http://www.mcherm.com/publish/2004-10-17/config.py
    http://www.mcherm.com/publish/2004-10-17/configTest.py

Thanks in advance for reviewing this.

-- Michael Chermside




More information about the Python-list mailing list