[Python-checkins] cpython: Update code to increment and decrement using the cleaner += 1 and -= 1 style.

raymond.hettinger python-checkins at python.org
Mon Mar 11 01:58:08 CET 2013


http://hg.python.org/cpython/rev/28b86525ef07
changeset:   82591:28b86525ef07
parent:      82589:c33781454880
user:        Raymond Hettinger <python at rcn.com>
date:        Sun Mar 10 15:13:35 2013 -0700
summary:
  Update code to increment and decrement using the cleaner += 1 and -= 1 style.

files:
  Lib/threading.py |  8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Lib/threading.py b/Lib/threading.py
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -79,7 +79,7 @@
     def acquire(self, blocking=True, timeout=-1):
         me = get_ident()
         if self._owner == me:
-            self._count = self._count + 1
+            self._count += 1
             return 1
         rc = self._block.acquire(blocking, timeout)
         if rc:
@@ -261,7 +261,7 @@
                         break
             self._cond.wait(timeout)
         else:
-            self._value = self._value - 1
+            self._value -= 1
             rc = True
         self._cond.release()
         return rc
@@ -270,7 +270,7 @@
 
     def release(self):
         self._cond.acquire()
-        self._value = self._value + 1
+        self._value += 1
         self._cond.notify()
         self._cond.release()
 
@@ -506,7 +506,7 @@
 _counter = 0
 def _newname(template="Thread-%d"):
     global _counter
-    _counter = _counter + 1
+    _counter += 1
     return template % _counter
 
 # Active thread administration

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list