__init__.py 文件源码

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

项目:midict 作者: ShenggaoZhu 项目源码 文件源码
def __setattr__(self, item, value):
        """Maps attributes to values.
        Only if initialized and there *isn't* an attribute with this name
        """
        # Note: this allows normal attributes access in the __init__ method

        super_setattr = super(AttrDict, self).__setattr__

        if '_AttrDict__attr2item' not in self.__dict__:  # slot??
            return super_setattr(item, value)

        if item in dir(self):  # any normal attributes are handled normally
            return super_setattr(item, value)

        return self.__setitem__(item, value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号