1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #4040 -- Changed uses of has_key() to "in". Slight performance

improvement and forward-compatible with future Python releases. Patch from Gary
Wilson.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2007-04-26 13:30:48 +00:00
parent 6c02565e4f
commit 439cb4047f
37 changed files with 112 additions and 92 deletions

View File

@@ -35,7 +35,7 @@ class Context(object):
def __getitem__(self, key):
"Get a variable's value, starting at the current context and going upward"
for d in self.dicts:
if d.has_key(key):
if key in d:
return d[key]
raise KeyError(key)
@@ -45,7 +45,7 @@ class Context(object):
def has_key(self, key):
for d in self.dicts:
if d.has_key(key):
if key in d:
return True
return False
@@ -54,7 +54,7 @@ class Context(object):
def get(self, key, otherwise=None):
for d in self.dicts:
if d.has_key(key):
if key in d:
return d[key]
return otherwise