How to escape a % sign in a configobj value?

Viewed 10135

I'd like to use both parse time and runtime interpolation for values of a configobj configuration file. The easiest way to do simple string interpolation in Python is "%(foo)s" % somedict. Unfortunately configobj uses the same interpolation mechanism and I have not yet found a way to escape it. Ideally my value would look like:

othervar = foo
someconfigobjkey = %(othervar)s %%(runtimevar)s

However configobj tries (and fails) to replace the second variable. Another way to answer this question is to provide a different (configobj) way to do both parse time and runtime interpolation.

5 Answers
Related