If you must you can do something like this:
example.conf :
[section]
a = 10
b = 15
c = %(a)s+%(b)s
d = %(b)s+%(c)s
and in your script you can do:
import ConfigParser
config = ConfigParser.SafeConfigParser()
config.readfp(open('example.conf'))
print config.get('section', 'a')
# '10'
print config.get('section', 'b')
# '15'
print config.get('section', 'c')
# '10+15'
print config.get('section', 'd')
# '15+10+15'
and you can eval the expression :
print eval(config.get('section', 'c'))
# 25
print eval(config.get('section', 'd'))
# 40
If i may suggest i think that ConfigParser modules classes are missing a function like this, i think the get() method should allow to pass a function that will eval the expression :
def my_get(self, section, option, eval_func=None):
value = self.get(section, option)
return eval_func(value) if eval_func else value
setattr(ConfigParser.SafeConfigParser, 'my_get', my_get)
print config.my_get('section', 'c', eval)
# 25
# Method like getint() and getfloat() can just be writing like this:
print config.my_get('section', 'a', int)
# 10