(fullpath)
return module
Import a Python module from a path.
Import a Python module from a path.
Import a Python module from a path .
def runfile(fullpath):
    """
    Import a Python module from a path.
    """
    # Change the working directory to the directory of the example, so
    # it can get at its data files, if any.
    pwd = os.getcwd()
    path, fname = os.path.split(fullpath)
    sys.path.insert(0, os.path.abspath(path))
    stdout = sys.stdout
    sys.stdout = cStringIO.StringIO()
    os.chdir(path)
    try:
        fd = open(fname)
        module = imp.load_module("__main__", fd, fname, ('py', 'r', imp.PY_SOURCE))
    finally:
        del sys.path[0]
        os.chdir(pwd)
        sys.stdout = stdout
    return module
def runfile ( fullpath ) : # Change the working directory to the directory of the example, so # it can get at its data files, if any. pwd = os . getcwd ( ) path , fname = os . path . split ( fullpath ) sys . path . insert ( 0 , os . path . abspath ( path ) ) stdout = sys . stdout sys . stdout = cStringIO . StringIO ( ) os . chdir ( path ) try : fd = open ( fname ) module = imp . load_module ( "__main__" , fd , fname , ( 'py' , 'r' , imp . PY_SOURCE ) ) finally : del sys . path [ 0 ] os . chdir ( pwd ) sys . stdout = stdout return module