[Python-Dev] Changes to ConfigParser
Greg Stein
gstein@lyra.org
Tue, 11 Jul 2000 03:35:34 -0700
On Tue, Jul 11, 2000 at 12:10:41PM +0200, Peter Funk wrote:
> Greg Stein :
> > On Tue, Jul 11, 2000 at 09:12:29AM +0200, Peter Funk wrote:
> > > Hi,
> > >
> > > Eric S. Raymond:
> > > > Earlier today, I committed a patch to ConfigParser that adds three new
> > > > methods to the class. Here is the documentation:
> > > [...]
> > > Applying the well known dictionary API to config info can help to
> > > to avoid reinventing a new API to deal with configuration info.
> > >
> > > What I would love to see, is a class 'ConfigDict' derived from
> > > 'UserDict.UserDict', which contains the section-names as keys and
> > > section-objects as values, where section-objects are also dictionaries
> > > containing the option-names as keys.
> >
> > Then go ahead and code it. I guarantee that you'll have your wish if you
> > code it. Otherwise, I'll lay very low odds on all the new module suggestions
> > in your email.
>
> Okay: I just had a look into the implementation of ConfigParser and
> stumbled over the '%(foo)' macro expansion features. If I go ahead and
> implement these within (below) my ConfigDict.__getitem__ method, this
> will lead to the problem, that
> cnf['some_section']['foo'] = 'feeble'
> cnf['some_section']['bar'] = 'baz'
> cnf['some_section']['some_option'] = '%(foo)/paf/%(bar)'
> print cnf['some_section']['some_option']
> might surprise users with the dictionary model in their head.
> They might expect this to print '%(foo)/paf/%(bar)' instead of
> 'feeble/paf/baz'.
>
> Any suggestions?
It is a configuration dictionary. Users can simply deal with it :-)
I'm not sure it is a big problem to worry about.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/