你可以同时得到:
import importlib, inspect for name, cls in inspect.getmembers(importlib.import_module("myfile"), inspect.isclass):
if cls.__module__ == 'myfile'