Your operator is tryincorrect. It should have been -
def testFunction(entity):
try: return callable(eval(entity))
except NameError:
return False
You also do not need to call a function (to check its presence or not). Above, the built-in function callableis used to check if a entityfunction / class or so.
( , module.function), , globals() , eval(). -
def testFunction(entity):
try: return callable(globals()[entity])
except KeyError:
return False
, True , - module.function .. , , entity, eval.