diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-04 20:44:31 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-04 20:44:31 (GMT) |
commit | b9da9bc0a04b718e8395e2e88c3053ab944579b7 (patch) | |
tree | 39e44e2cc664befbe4ede987ad71ea37db3bb7b0 /Lib/_abcoll.py | |
parent | 15ebc88d87d2ff8f520581a9f6a6816d78a7e504 (diff) | |
download | cpython-b9da9bc0a04b718e8395e2e88c3053ab944579b7.zip cpython-b9da9bc0a04b718e8395e2e88c3053ab944579b7.tar.gz cpython-b9da9bc0a04b718e8395e2e88c3053ab944579b7.tar.bz2 |
Start replacing UserDict.DictMixin with collections.MutableMapping (the bsddb modules are next).
Diffstat (limited to 'Lib/_abcoll.py')
-rw-r--r-- | Lib/_abcoll.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 005f437..de6e6f8 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -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) |