Source

pythonwise / import_any.py

1
2
3
4
5
6
7
from types import ModuleType

def import_any(path, name=None):
    module = ModuleType(name or "dummy")
    execfile(path, globals(), module.__dict__)

    return module