#!/usr/bin/python
from ConfigParser import *
configuration_file = "test.conf" substitution = {"xyzzy":"maze"} configuration = SafeConfigParser() configuration.readfp(file(configuration_file))
list = configuration.items("core") print list
list = configuration.items("core",0, substitution) print list
---------------
and this configuration file
-----------
[core] xyzzy=little bird dwarf = greasy smoke %(xyzzy)s plugh
------------ why do I get the following results?
-------------
trial backup # python test.py [('dwarf', 'greasy smoke little bird plugh'), ('xyzzy', 'little bird')] [('dwarf', 'greasy smoke maze plugh'), ('xyzzy', 'maze')] trial backup #
-------------
if you're having a hard time seeing it, before the substitution, xyzzy is set to the value in the configuration file, afterwards, it is set to the value of the substitution in the code. It seems to me that substitutions should not affect any configuration file symbols of the same name.
anyway to fix this problem without python diving?
---eric
-- http://mail.python.org/mailman/listinfo/python-list