]> granicus.if.org Git - python/commitdiff
Sync-up with Py3k work.
authorRaymond Hettinger <python@rcn.com>
Wed, 6 Feb 2008 01:49:00 +0000 (01:49 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 6 Feb 2008 01:49:00 +0000 (01:49 +0000)
Lib/_abcoll.py

index 89d41796b24d2da741a14e1835e14d2a596b0cf9..0519d42335bf11468e3470eba78211607871770c 100644 (file)
@@ -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)