mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Sync-up with Py3k work.
This commit is contained in:
parent
b70907796a
commit
45eda64691
1 changed files with 13 additions and 0 deletions
|
@ -345,6 +345,12 @@ class Mapping:
|
|||
def values(self):
|
||||
return ValuesView(self)
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, Mapping) and \
|
||||
dict(self.items()) == dict(other.items())
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
class MappingView:
|
||||
__metaclass__ = ABCMeta
|
||||
|
@ -453,6 +459,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