From 45eda6469124855d349666184c6f92058a9e08f0 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 6 Feb 2008 01:49:00 +0000 Subject: Sync-up with Py3k work. --- Lib/_abcoll.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 89d4179..0519d42 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -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) -- cgit v0.12