ConfigParser and options

Matej Cepl cepl at surfbest.net
Wed Feb 12 18:40:36 EST 2003


Hi,

I would like to write a config file parser, but I would like to allow
user to
set just some options (when he wants a default values for the rest of
them). How can I do it?

I can write something like

for rcvar in rcconfile.options(currsection):
     ...
     variable = get(currsection,rcvar)

but how do I connect variable to the real variable which is equal to
the name of the option in the file? Other option is to go in one huge
if ... construct

if rcconfile.has_key(currsection,'variable1'):
     variable1 = rcconfile.get(currsection,'variable1')
if rcconfile.has_key(currsection,'variable2'):
     variable2 = rcconfile.get(currsection,'variable2')
if ...

but it is really ugly, isn't it?

Thanks in advance for any help,

    Matej

P.S.: Please Cc: to my emaili address -- I am not subscribed.




More information about the Python-list mailing list