lightweight human-readable config?

Noen not.available at na.no
Wed Oct 29 18:36:21 EST 2003


John Roth wrote:


> "Maxim Khesin" <max at cNvOiSsiPoAnMtech.com> wrote in message
> news:p4Xnb.17367$Gq.5475490 at twister.nyc.rr.com...
> 
>>I want to have a config file with my python proggie, satisfying the
>>following requirements:
>>1) support key->(value, default)
>>2) simple and intuitive to read and edit
>>3) easyly readable into a python datastructure (a dictionary?)
>>4) not requiring any heavy libraries needed (I am distributing my
>>proggie as a py2exe executable and do not want to bloat the size)
>>
>>can you guys suggest some format for this? thanks,
>>max
> 
> 
> A text file containing lines formatted as:
> 
> key: value
> 
> for line in inFile.readlines():
>     key, value = line.split(":")
>     configdict[key] = value
> 
> I usually like to add a statement that filters out lines
> that start with a "#" character.
> 
> Elaborate to taste.
> 
> John Roth
You could try out
This format is already avaiable as a python module following the .ini 
format (RFC 822).
The format is like this
[SECTION]
varname1: var
varname2: var
varname3: var
varname4: var
...
Compiled using the -OO, its size is.
30.10.2003  00:33            13 483 ConfigParser.pyo

Enjoy -- Noen
> 
> 
> 
> 
> 





More information about the Python-list mailing list