I am trying to call a function from a module. The module and the function have the same name, which is read at runtime using
TypeError: 'str' object is not callable
As Jon mentioned, you didn't save a reference to the imported module. You need that to call its functions. To actually get to the function you can use the built-in
getattr function. Eg,
ent = "module" mod = __import__(ent) func = getattr(mod, ent) func()
__import__ is rather unusual, and only done in special situations. Is your situation special enough to warrant its use?