lightweight human-readable config?

John Roth newsgroups at jhrothjr.com
Wed Oct 29 17:49:53 EST 2003


"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


>






More information about the Python-list mailing list