diff options
| author | Raymond Hettinger <python@rcn.com> | 2008-02-06 01:49:00 (GMT) |
|---|---|---|
| committer | Raymond Hettinger <python@rcn.com> | 2008-02-06 01:49:00 (GMT) |
| commit | 45eda6469124855d349666184c6f92058a9e08f0 (patch) | |
| tree | 4e879cb5b1184f3e0b4c34cfb03b6b030d1a7371 | |
| parent | b70907796ac6e911f8683cce354fdeb94d24d73f (diff) | |
| download | cpython-45eda6469124855d349666184c6f92058a9e08f0.zip cpython-45eda6469124855d349666184c6f92058a9e08f0.tar.gz cpython-45eda6469124855d349666184c6f92058a9e08f0.tar.bz2 | |
Sync-up with Py3k work.
| -rw-r--r-- | Lib/_abcoll.py | 13 |
1 files changed, 13 insertions, 0 deletions
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) |
