mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Start replacing UserDict.DictMixin with collections.MutableMapping (the bsddb modules are next).
This commit is contained in:
parent
15ebc88d87
commit
b9da9bc0a0
4 changed files with 19 additions and 7 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue