wangzhibo
2025-07-27 594d916c67b2f8168a8817756bd7ac749ac5de3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# __init__.py
 
import os
import importlib
import inspect
 
__all__ = []
 
package_name = __name__
package_dir = os.path.dirname(__file__)
 
for filename in os.listdir(package_dir):
    if filename.endswith(".py") and not filename.startswith("__"):
        module_name = filename[:-3]
        full_module_path = f"{package_name}.{module_name}"
        module = importlib.import_module(full_module_path)
        for name, obj in inspect.getmembers(module, inspect.isclass):
            if obj.__module__ == full_module_path:
                globals()[name] = obj
                __all__.append(name)