From 439cb4047fb583d08149f28e2ce66a8edfe0efa7 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 26 Apr 2007 13:30:48 +0000 Subject: 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 --- django/utils/datastructures.py | 2 +- django/utils/functional.py | 2 +- django/utils/translation/trans_real.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'django/utils') diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index cca30b462d..60bc0051a2 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -42,7 +42,7 @@ class MergeDict(object): def has_key(self, key): for dict in self.dicts: - if dict.has_key(key): + if key in dict: return True return False diff --git a/django/utils/functional.py b/django/utils/functional.py index e3c0a3c76b..0c31c1f375 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -42,7 +42,7 @@ def lazy(func, *resultclasses): res = self.__func(*self.__args, **self.__kw) return self.__dispatch[type(res)][funcname](res, *args, **kw) - if not self.__dispatch.has_key(klass): + if klass not in self.__dispatch: self.__dispatch[klass] = {} self.__dispatch[klass][funcname] = func return __wrapper__ diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 0c8dcd540f..293b4ef9cd 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -199,7 +199,7 @@ def deactivate(): will resolve against the default translation object, again. """ global _active - if _active.has_key(currentThread()): + if currentThread() in _active: del _active[currentThread()] def get_language(): -- cgit v1.3