Hi, I have a program that picks module and method name from a configuration file and executes the method. I have found two ways to achieve this.
Apporach 1: --------------------------- moduleName = 'mymodule' #These two variables are read from conf file. methodName = 'mymethod' import operator myModule = __import__('mymodule') myMethod = operator.methodcaller('mymethod') val = myMethod(myModule) print val --------------------------- Apporach 2: --------------------------- moduleName = 'mymodule' #These two variables are read from conf file. methodName = 'mymethod' val = eval('myModule.' + methodName + '()') print val --------------------------- Question: Which approach is better and why. Is there any other better way to do this? Regards, Laxmikant -- http://mail.python.org/mailman/listinfo/python-list