Created
January 18, 2016 16:55
-
-
Save cescoferraro/ddad728b227f75d13a36 to your computer and use it in GitHub Desktop.
Import all files inside a 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
import importlib | |
import os | |
for module in os.listdir(os.path.dirname(__file__)): | |
if module != '__init__.py': | |
if not str(module).endswith('.pyc'): | |
path= "scripts.%s"% module | |
# This is doing "import `file`" instead of "from `file` import *" | |
importlib.import_module(str(os.path.splitext(path)[0])) | |
del module | |
# this works! | |
from deploy import yoyo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment