I have a multimodule Python package which has one file with class
MyClass and few files with functions (one file can contain more than 1 function).
I tried to get all functions in this package.
Firstly, using the following:
modules = 
for importer, module, ispkg in pkgutil.iter_modules(package.__path__):
but I got only module names, not module objects.
When I tried to get functions of these modules using
inspect.getmembers(module, inspect.isfunction), I of course, got an empty collection.
So, how can I got all module objects from the package for further getting functions?
Does an easier way to get all functions from the multifile package exists?
P.S. I need exactly
function objects and not only their names.
dir(package) gives me only built-in variables:
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
inspect.getmembers(package, inspect.infunction) gives an empty
list as well as the same code for each
module as I described above.
dir(module) gives me the name list of all methods available for
str objects (because,
iter_modules() gives only names of
AST... Are you sure, that there isn't simpler solutions?