config.py 文件源码

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

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def __ImportFrom(module_xname, xname):
    """
    Import a specified name from a python module into the global namespace. This can be accomplished
    programatically and inside a method or class.

    @param module_xname : name of the module to load x.y.z
    @param xname :  symbol to import from loaded module
    @return method/class : imported item from loaded module
    """
    try:
        module = __import__(module_xname,globals(),locals(), [xname])
    except ImportError:
        return None

    try:
      module = getattr(module,xname)
      if xname:
        for x in range( len(inspect.stack()) ):
            inspect.currentframe(x).f_globals[xname]=module
    except AttributeError as e:
        module=None

    return module
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号