Dealing with config files what's the options

Fuzzyman fuzzyman at gmail.com
Wed Feb 23 03:30:34 EST 2005


Hello Tom,


Tom Willis wrote:
> How are the expert pythoneers dealing with config files?
>
> Is there anything similair to .net's config files or java's
.properties?
>

I'm not familiar with those config file formats - but ConfigObj
certainly makes handling config files easy. It uses the ini type layout
- which you're not so fond of, although it aloows lists for values as
well.

from configobj import ConfigObj
config = ConfigObj(filename)
value1 = config['section 1']['value 1']

See http://www.voidspace.org.uk/python/configobj.html

I'm interested in suggestions as to ways to take it forward. I've just
added unicode support (still experimental - wait for the next release)
and an interface for validation. Adding nested sections using
indentation will probably be the next major feature..... (as well as
preserving user formatting when writing back files)

Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

> A quick search on google didn't return anything that looked useful,
> and I almost would expect to see some module that would be for
dealing
> with config information.
>
> I can think of at least one way to do it, but I'm sure there are
> shortcomings I can't see yet, and I'd rather use something someone
> smarter than me has written.
>
> I see in the logging module that there's stuff to handle configs but
> seems kind of odd to have to import logging to get your config
> information
>
> Any ideas?
>
> have I used the word config enough in this message? :)
> 
> -- 
> Thomas G. Willis
> http://paperbackmusic.net




More information about the Python-list mailing list