Created
January 5, 2015 18:38
-
-
Save winniehell/d7598ebddb51a6c504a2 to your computer and use it in GitHub Desktop.
Find all python classes within the current package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import importlib | |
import inspect | |
import pkgutil | |
package = importlib.import_module(__package__) | |
for loader, module_name, is_pkg in pkgutil.iter_modules(package.__path__): | |
if not is_pkg: | |
module = importlib.import_module(__package__+'.'+module_name) | |
for name, obj in inspect.getmembers(module): | |
if inspect.isclass(obj): | |
print(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment