Quantcast
Viewing latest article 9
Browse Latest Browse All 22

Answer by trubliphone for Calling a function of a module by using its name (a string)

For what it's worth, if you needed to pass the function (or class) name and app name as a string, then you could do this:

myFnName  = "MyFn"
myAppName = "MyApp"
app = sys.modules[myAppName]
fn  = getattr(app,myFnName)

Viewing latest article 9
Browse Latest Browse All 22

Trending Articles