Home:ALL Converter>How to find some specific classes from all available modules in Python?

How to find some specific classes from all available modules in Python?

Ask Time:2015-03-13T01:32:11         Author:ereOn

Json Formatter

I'm designing a command line tool and I'd like to implement a Plugin feature.

The idea would be that upon startup, the tool scans all packages in its current virtualenv and lists all classes that inherit from a specific base class (say foo.BasePlugin).

I found easily how to get the list of installed modules but I have no idea how to list the classes for each listed package/distribution.

Is there a way to list all defined classes in all modules of the current virtualenv ?

Author:ereOn,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29016509/how-to-find-some-specific-classes-from-all-available-modules-in-python
yy