import imp


def __import__(name, path):
    """
    Imports a module that is outside of python path.

    Modified from Python Library Reference.

    Arguments:
      - name: module name (file name without '.py')
      - path: directory where the module resides, relative to the directory
        of the calling function

    Returns: module, on None if module not found
    """

    # do not check if the module has already been imported, because a different
    # module with the same name might have been already imported
    #try:
    #    return sys.modules[name]
    #except KeyError:
    #    pass

    # import
    try:
        fp, pathname, description = imp.find_module(name, [path])
    except Exception:
        return None
    try:
        return imp.load_module(name, fp, pathname, description)
    except ImportError:
        return None
    finally:
        # since we may exit via an exception, close fp explicitly.
        if fp:
            fp.close()