def runFunction(moduleName, functionName, argsTuple): exec 'import ' + moduleName module = eval(moduleName) function = getattr(module, functionName) return apply(function, argsTuple) if __name__ == '__main__': from sys import argv print runFunction(argv[1], argv[2], tuple(argv[3:]))