]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
_once(): Simplified dict manipulation.
authorTim Peters <tim.peters@gmail.com>
Tue, 13 Aug 2002 23:29:21 +0000 (23:29 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 13 Aug 2002 23:29:21 +0000 (23:29 +0000)
Lib/tempfile.py

index 32b83a0801ce3fcc2248672cde5d7b8fc5dfe1ae..dff2ae937fc5349cdf4105d21b2375faa5880617 100644 (file)
@@ -101,12 +101,12 @@ def _once(var, initializer):
     lock = _once_lock
 
     # Check first outside the lock.
-    if var in vars and vars[var] is not None:
+    if vars.get(var) is not None:
         return
     try:
         lock.acquire()
         # Check again inside the lock.
-        if var in vars and vars[var] is not None:
+        if vars.get(var) is not None:
             return
         vars[var] = initializer()
     finally: