__init__.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:pydbvolve 作者: Teamworksapp 项目源码 文件源码
def import_arbitrary(fileName, modName):
    """
    Returns a module reference.
    This function acts like a Python import statement, but it will 
    import an arbitrary Python file located at any path.
    """

    importlib.invalidate_caches()

    loader = ilmac.SourceFileLoader(modName.replace('.', '_'), fileName)
    spec = ilutil.spec_from_loader(loader.name, loader)
    mod = ilutil.module_from_spec(spec)
    loader.exec_module(mod)

    return mod
# End import_arbitrary
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号