Skip to content

Instantly share code, notes, and snippets.

@Maome
Created July 12, 2016 23:08
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 Maome/d9509132d42fc0c41782591660c63832 to your computer and use it in GitHub Desktop.
Save Maome/d9509132d42fc0c41782591660c63832 to your computer and use it in GitHub Desktop.
import imp
from glob import glob
import os
basedir = os.path.dirname(os.path.abspath(__file__))
def load():
modules = []
paths = glob(os.path.join(basedir, "*.py"))
for path in paths:
filename = os.path.basename(path)
if filename == '__init__.py':
continue
name, ext = os.path.splitext(filename)
modules.append(imp.load_source(name, path))
return modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment