Following the phihag hint, I have this solution. Just specify the path to the source file load_src and it will load it. You must also provide a name so that you can import this module using this name. I prefer to do it like this because it is more explicit:
def load_src(name, fpath): import os, imp return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath)) load_src("util", "../util.py") import util print util.method()
Another (less explicit) way:
util = load_src("util", "../util.py")
Edit: This method has been rewritten to make it more understandable.
Jabba Jan 01 '14 at 16:27 2014-01-01 16:27
source share