a ConfigParser wtf moment

Eric S. Johansson esj at harvee.org
Thu Jan 13 23:27:49 EST 2005

grahamd at dscpl.com.au wrote:
> To avoid this, you need to write something like:
> .  list = []
> .  for key in configuration.options("core"):
> .     list.append((key,configuration.get("core",substitution))
> .  print list
> This cause me problems for a different reason, ie., that user vars keys
> appear in what items() returns. I avoid using items() for this reason.

it turns out, I originally discovered this problem through the get with 
substitutions.  It's too late to muck with it now but if you are really 
interested I will generate a test case showing the failure or else prove 
I was hallucinating.

My current workaround is to look for a %( in every value returned and if 
so do a string substitution.

	value = base.get(section,item, 1)
         if value.find("%(") != -1:
           value = value% self.interpolation_symbols

yes, it is as ugly as a roadkill toad but it gets the job done.  I've 
spent away too much time on this problem for this particular project.  I 
think we all know the feeling.


More information about the Python-list mailing list