import importlib import os import pkgutil pkg_dir = os.path.dirname(__file__) all_plugins = {} for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]): if not name.startswith('_'): cls = importlib.import_module('.' + name, __package__).Plugin all_plugins[name] = cls