def __eq__(self, other):
'''
>>> viewabledict({}) == viewabledict({})
True
>>> viewabledict({}) != viewabledict({1:1})
True
>>> viewabledict({1:1,3:3}) != viewabledict({1:1,2:2})
True
>>> viewabledict({1:1,2:2}) + viewabledict({3:3}) == viewabledict({1:1,2:2,3:3})
True
>>> viewabledict({}) + viewabledict({3:3}) == viewabledict({3:3})
True
'''
if not isinstance(other, Mapping):
return False
return all(a == b for a, b in zip_longest(
self.iteritems(), other.iteritems(), fillvalue=_NO_VAL))
评论列表
文章目录