ConfigParser: Can I read(ConfigParser.get()) a configuration file and use it to call a funciton?

jamitwidme at jamitwidme at
Thu Jun 26 22:01:39 CEST 2008

Thank you for the answers.
Now I understood how to call a function, let me ask you another

title: abcd
function: efgh
import ConfigParser

class Functions:
   def efgh(self):
      print 'blah'

fcn = Functions()

config = ConfigParser.ConfigParser()'configuration.cfg')
title = config.get('1234','title')         # number 1
function_name = config.get('1234','function')

title = getattr(fcn, function_name)

instead of assigning string value('abcd') to title at number 1

I want to assign this function(fcn.efgh()) to abcd and make abcd a
so later on, I want to call it by abcd(), not title().
The reason is I will have a loop reading from configuration file, so I
need to have different names for each function.
abcd is a string I read got it from config.get('1234','title')

Thanks again.

More information about the Python-list mailing list