jstraitlets.py 文件源码

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

项目:schemapi 作者: altair-viz 项目源码 文件源码
def __init__(self, **kwargs):
        # make a copy of the _metadata so we can modify locally
        self._metadata = self._metadata.copy()

        # Add default traits if needed
        default = self._get_additional_traits()
        # TODO: protect against overwriting class attributes defined above.
        #       perhaps use double underscores?
        if default:
            all_traits = self.traits()
            self.add_traits(**{key: default for key in kwargs
                               if key not in all_traits})

        # Validate keywords to make sure they are valid traits
        all_traits = list(self.traits())
        for k in kwargs:
            if k not in all_traits:
                raise T.TraitError("Invalid trait: {0}. Options for "
                                   "this class: {1}".format(k, all_traits))

        super(JSONHasTraits, self).__init__(**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号