summaryrefslogtreecommitdiffstats
path: root/Lib/UserDict.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-01-22 01:39:06 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-01-22 01:39:06 (GMT)
commit51f3f1b7dce6d054891faf9959fc493e66e9f684 (patch)
tree6cbba44294fbd8f8a0bf108aced7d66a17fbc3e5 /Lib/UserDict.py
parent981344567fb810a68c7a371c4727f3f63a181214 (diff)
downloadcpython-51f3f1b7dce6d054891faf9959fc493e66e9f684.zip
cpython-51f3f1b7dce6d054891faf9959fc493e66e9f684.tar.gz
cpython-51f3f1b7dce6d054891faf9959fc493e66e9f684.tar.bz2
SF patch #667730: More DictMixin
Sebastien Keim pointed out that iterkeys and __contains__ require their own definitions so their behavior will update when the underlying method is subclassed.
Diffstat (limited to 'Lib/UserDict.py')
-rw-r--r--Lib/UserDict.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index 34ceb3a..f9ad471 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -90,13 +90,15 @@ class DictMixin:
except KeyError:
return False
return True
- __contains__ = has_key
+ def __contains__(self, key):
+ return self.has_key(key)
# third level takes advantage of second level definitions
def iteritems(self):
for k in self:
yield (k, self[k])
- iterkeys = __iter__
+ def iterkeys(self):
+ return self.__iter__()
# fourth level uses definitions from lower levels
def itervalues(self):