ConfigParser shootout, preliminary entry

Michael Foord fuzzyman at gmail.com
Mon Oct 18 10:45:25 CEST 2004


Config file reading is an area where python is 'well served' with
various options.
For sheer simplicty of use you can't beat my ConfigObj. It reads the
file and presents the values as a dictionary (keyed by keyword of
course). It supports writing hte file as well. The trouble with with
using attribute names is that you will have problems with keywords
that are reserved - like 'print' and 'pass'.

Of course the obligatory URL
http://www.voidspace.org.uk/atlantibots/configobj.html

Regards,

Fuzzyman

http://www.voidpace.org.uk/atlantibots/pythonutils.html

Michael Chermside <mcherm at mcherm.com> wrote in message news:<mailman.5093.1098051158.5135.python-list at python.org>...
> 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