Last active
July 12, 2023 02:32
-
-
Save jizhang/d2e19271b4d71eb3ef563c22c2718e01 to your computer and use it in GitHub Desktop.
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
def import_submodules(package) -> None: | |
package = importlib.import_module(package) | |
for _, name, is_pkg in pkgutil.iter_modules(package.__path__): | |
full_name = package.__name__ + '.' + name | |
if is_pkg: | |
import_submodules(full_name) | |
else: | |
importlib.import_module(full_name) | |
import_submodules(__package__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment