summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-21 19:24:53 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-21 19:24:53 (GMT)
commit31ce5cb989da7a8362b7ea232fc263f0fb738a75 (patch)
tree676b71d92894661253c5ddf87fd785bbf6d146eb
parent8982cf5484e0203bc4505cdf13a5f797f477327a (diff)
downloadcpython-31ce5cb989da7a8362b7ea232fc263f0fb738a75.zip
cpython-31ce5cb989da7a8362b7ea232fc263f0fb738a75.tar.gz
cpython-31ce5cb989da7a8362b7ea232fc263f0fb738a75.tar.bz2
Update more instances of has_key().
-rw-r--r--Lib/UserDict.py4
-rw-r--r--Lib/shelve.py6
2 files changed, 5 insertions, 5 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index a786ae0..39f4d07 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -41,7 +41,7 @@ class UserDict:
def iterkeys(self): return self.data.iterkeys()
def itervalues(self): return self.data.itervalues()
def values(self): return self.data.values()
- def has_key(self, key): return self.data.has_key(key)
+ def has_key(self, key): return key in self.data
def update(self, dict=None, **kwargs):
if dict is None:
pass
@@ -59,7 +59,7 @@ class UserDict:
return failobj
return self[key]
def setdefault(self, key, failobj=None):
- if not self.has_key(key):
+ if key not in self:
self[key] = failobj
return self[key]
def pop(self, key, *args):
diff --git a/Lib/shelve.py b/Lib/shelve.py
index 7a75445..f1a468e 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -95,13 +95,13 @@ class Shelf(UserDict.DictMixin):
return len(self.dict)
def has_key(self, key):
- return self.dict.has_key(key)
+ return key in self.dict
def __contains__(self, key):
- return self.dict.has_key(key)
+ return key in self.dict
def get(self, key, default=None):
- if self.dict.has_key(key):
+ if key in self.dict:
return self[key]
return default