converters.py 文件源码

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

项目:cattrs 作者: Tinche 项目源码 文件源码
def structure_attrs_fromdict(self, obj, cl):
        # type: (Mapping, Type) -> Any
        """Instantiate an attrs class from a mapping (dict)."""
        # For public use.
        conv_obj = obj.copy()  # Dict of converted parameters.
        for a in cl.__attrs_attrs__:
            name = a.name
            # We detect the type by metadata.
            converted = self._structure_attr_from_dict(a, name, obj)
            if converted is not NOTHING:
                conv_obj[name] = converted

        return cl(**conv_obj)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号