Skip to content

Instantly share code, notes, and snippets.

@cescoferraro
Created January 18, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cescoferraro/ddad728b227f75d13a36 to your computer and use it in GitHub Desktop.
Save cescoferraro/ddad728b227f75d13a36 to your computer and use it in GitHub Desktop.
Import all files inside a package
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