Last active
August 29, 2015 14:06
-
-
Save jtprince/728377e2308c60693931 to your computer and use it in GitHub Desktop.
dynamically include all files in folder with the package (and alternatively import each of those source files)
This file contains hidden or 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 | |
_python_source_files = list( | |
filter( | |
lambda basename: basename.endswith(".py") and | |
not basename.startswith('_'), | |
os.listdir( os.path.dirname(os.path.realpath(__file__)) ) | |
) | |
) | |
__all__ = [fn[:-3] for fn in _python_source_files] | |
del _python_source_files | |
# uncomment below if you want to import the submodules into the package namespace | |
# NOT sure if the blow works properly, but above works | |
# for mod in __all__: __import__(mod) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment