ConfigParser module and alternatives (flad, flan)

Mark Nottingham mnot at pobox.com
Mon Apr 12 17:50:02 EDT 1999


Just to jump in here (haven't read the whole thread, I've been away for a
while and BOY is my mail piled up), you might have some luck the
underdeveloped Conf.py module if ConfigParser doesn't do it for you --

http://www.pobox.com/~mnot/script/python/


----- Original Message -----
From: Jim Meier <fatjim at home.com>
Newsgroups: comp.lang.python
To: <python-list at cwi.nl>
Sent: Tuesday, April 13, 1999 1:59
Subject: Re: ConfigParser module and alternatives (flad, flan)


>
>
> Mike Orr wrote:
>
> > I'm not sure if I'll use ConfigParser for the next version.  I don't
> > really need the sections (multiple files work just fine, using the
filename
> > for the section name), and I haven't found a use for the the
%(other_key)s
> > substitutions.  On the other hand, it doesn't handle multiple values
(the
> > same key repeated within a record), which I sometimes need.
> >
> > Attached is a wrapper class for ConfigParser which supports booleans
> > and can also return an entire section as a dictionary (or all the
sections
> > as nested dictionaries).  I find these make it a little more convenient.
> >
>
> Why not simply use a file of python expressions? Like this:
>
> {'section1': {
>     'key1':[1,2,3,'value',['useful','nesting','eh?']],
>     'key2':'anotherval'
>     },
> 'section2': {
>     'subsection':{
>         'subkey':5
>         }
>     }
> }
>
> I beleive you can even use variable names in such files for
application-specified
> substitutions, like this:
>
> (python app defines variable "rootdir")
>
> {'pathssection': {
>     'fontpath': rootdir+'/font/'
>     }
> }
>
> This introduces some major security problems, and is a little difficult to
edit,
> but there is very little parsing needed to make it usable.  Does anyone
know of a
> way to limit the damage a user can do to such a file?
>
> Another idea is to run your config file through a simple macro utility (or
do the
> macro conversion in python itself) to convert it into python code to eval.
>
> Jim Meier
>
>
>





More information about the Python-list mailing list