ConfigParser does not substitute

Berthold Hoellmann hoel at
Wed May 3 12:48:16 CEST 2000


Why does ConfigParser does not resolve my references. With the following
config file (samp1.config):

DK_1: (group == %(deck)s )

and a small python script called conftest.:

from ConfigParser import ConfigParser

p = ConfigParser()'samp1.config')

for s in p.sections():
    print "section: %s" % s
    for o in p.options(s):
        print "option for '%s' is '%s' with value '%s'" % (s, o,
p.get(s, o))
print "defaults: ", p.defaults()

I get:

section: funcel
option for 'funcel' is 'deck' with value '25'
option for 'funcel' is 'dk_1' with value '(group == %(deck)s )'
option for 'funcel' is '__name__' with value 'funcel'
defaults:  {'deck': '25'}

I expected to get

option for 'funcel' is 'dk_1' with value '(group == 25 )'

Why didn't I.


email: hoel at
C[_]  These opinions might be mine, but never those of my employer.

More information about the Python-list mailing list