86 lines
2.4 KiB
Plaintext
86 lines
2.4 KiB
Plaintext
From: mnot at pobox.com (Mark Nottingham)
|
|
Date: Mon, 12 Apr 1999 21:50:02 GMT
|
|
Subject: ConfigParser module and alternatives (flad, flan)
|
|
References: <19990331160323.21601.00000471@ng-fi1.aol.com><7du3ab$3ag@chronicle.concentric.net><jtaewsfmlj.fsf@wazor.biostat.wisc.edu><xcxP2.1302$rd2.27684@news14.ispnews.com> <371219E9.9EA91839@home.com>
|
|
Message-ID: <003801be852e$6b8f5d20$0301a8c0@cbd.net.au>
|
|
Content-Length: 2010
|
|
X-UID: 1137
|
|
|
|
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
|
|
>
|
|
>
|
|
>
|
|
|
|
|
|
|
|
|
|
|