Another option is to use INSPECT and the getmembers (modulename) function.
It will return a complete list of what is in the module, which can then be cached. eg.
>>>cache = dict(inspect.getmembers(module)) >>>cache["__name__"] Pyfile1 test >>>cache["__email__"] ' name@email.com ' >>>cache["test"]("abcdef") test, abcdef
The advantage here is that you search only once, and it is assumed that the module does not change during program execution.
Benjamin schollnick
source share