Last active
March 11, 2019 09:13
-
-
Save SuoXC/83550148a41778f4d032033496ec0b6d to your computer and use it in GitHub Desktop.
auto register sub modules in current dir
This file contains 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 os | |
import importlib | |
# 自动注册当前文件夹下所有模块 | |
module_dir = os.path.dirname(__file__) | |
for i in os.listdir(module_dir): | |
module_name = os.path.basename(i).split('.')[0] | |
importlib.import_module('.' + module_name, __package__) | |
# usage: | |
# import a | |
# a.b.xxxx() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment