Kaydet (Commit) 51f3f1b7 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

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.
üst 98134456
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment