Start replacing UserDict.DictMixin with collections.MutableMapping (the bsddb modules are next).

This commit is contained in:
Raymond Hettinger 2008-02-04 20:44:31 +00:00
parent 15ebc88d87
commit b9da9bc0a0
4 changed files with 19 additions and 7 deletions

View file

@ -378,6 +378,11 @@ class Mapping(metaclass=ABCMeta):
def values(self):
return ValuesView(self)
def __eq__(self, other):
return set(self) == set(other)
def __ne__(self, other):
return set(self) == set(other)
class MappingView(metaclass=ABCMeta):
@ -485,6 +490,13 @@ class MutableMapping(Mapping):
for key, value in kwds.items():
self[key] = value
def setdefault(self, key, default=None):
try:
return self[key]
except KeyError:
self[key] = default
return default
MutableMapping.register(dict)