_pydev_SimpleXMLRPCServer.py 文件源码

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

项目:specto 作者: mrknow 项目源码 文件源码
def resolve_dotted_attribute(obj, attr, allow_dotted_names=True):
    """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d

    Resolves a dotted attribute name to an object.  Raises
    an AttributeError if any attribute in the chain starts with a '_'.

    If the optional allow_dotted_names argument is false, dots are not
    supported and this function operates similar to getattr(obj, attr).
    """

    if allow_dotted_names:
        attrs = attr.split('.')
    else:
        attrs = [attr]

    for i in attrs:
        if i.startswith('_'):
            raise AttributeError(
                'attempt to access private attribute "%s"' % i
                )
        else:
            obj = getattr(obj, i)
    return obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号