[Python-checkins] cpython: Issue 21469: Minor code modernization (convert and/or expression to an if/else

raymond.hettinger python-checkins at python.org
Tue May 13 07:22:58 CEST 2014


http://hg.python.org/cpython/rev/560320c10564
changeset:   90683:560320c10564
parent:      90681:0b90962e5f19
user:        Raymond Hettinger <python at rcn.com>
date:        Mon May 12 22:22:46 2014 -0700
summary:
  Issue 21469:  Minor code modernization (convert and/or expression to an if/else expression).

Suggested by: Tal Einat

files:
  Lib/urllib/robotparser.py |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py
--- a/Lib/urllib/robotparser.py
+++ b/Lib/urllib/robotparser.py
@@ -172,7 +172,7 @@
         return self.path == "*" or filename.startswith(self.path)
 
     def __str__(self):
-        return (self.allowance and "Allow" or "Disallow") + ": " + self.path
+        return ("Allow" if self.allowance else "Disallow") + ": " + self.path
 
 
 class Entry:

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


More information about the Python-checkins mailing list