Last active
September 29, 2022 22:47
-
-
Save ntessore/9da75daa573b83498ed7d259d2181f87 to your computer and use it in GitHub Desktop.
Automatically import all packages from a Python namespace package
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
# author: Nicolas Tessore <n.tessore@ucl.ac.uk> | |
# license: MIT | |
'''meta-module that imports all modules from its namespace package | |
Package this module in your namespace. Then use ``import mynamespace.all`` and | |
every module in the namespace will be available under the import. | |
''' | |
(lambda: [__import__(_.name) for _ in __import__('pkgutil').iter_modules(__import__(__package__).__path__, __package__ + '.')])() # noqa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment