diff options
author | Georg Brandl <georg@python.org> | 2006-06-09 20:43:48 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-06-09 20:43:48 (GMT) |
commit | b2afe855e5d75a570707d6bf0e32206e4b7b1c4d (patch) | |
tree | b637a7e78de40cf155c471e702e9b465fcd0625d | |
parent | 3ebef999e60cc63baafcdcfa0fd05c063715a66c (diff) | |
download | cpython-b2afe855e5d75a570707d6bf0e32206e4b7b1c4d.zip cpython-b2afe855e5d75a570707d6bf0e32206e4b7b1c4d.tar.gz cpython-b2afe855e5d75a570707d6bf0e32206e4b7b1c4d.tar.bz2 |
Make use of new str.startswith/endswith semantics.
Occurences in email and compiler were ignored due to backwards compat requirements.
-rw-r--r-- | Lib/_MozillaCookieJar.py | 3 | ||||
-rw-r--r-- | Lib/difflib.py | 5 | ||||
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/configHandler.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/configHelpSourceEdit.py | 5 | ||||
-rw-r--r-- | Lib/test/test_compiler.py | 2 | ||||
-rw-r--r-- | Lib/test/test_inspect.py | 2 | ||||
-rw-r--r-- | Lib/test/test_tcl.py | 6 | ||||
-rw-r--r-- | Lib/trace.py | 2 | ||||
-rw-r--r-- | Lib/warnings.py | 2 | ||||
-rw-r--r-- | Lib/webbrowser.py | 3 |
11 files changed, 14 insertions, 20 deletions
diff --git a/Lib/_MozillaCookieJar.py b/Lib/_MozillaCookieJar.py index 1776b93..4fd6de3 100644 --- a/Lib/_MozillaCookieJar.py +++ b/Lib/_MozillaCookieJar.py @@ -63,8 +63,7 @@ class MozillaCookieJar(FileCookieJar): if line.endswith("\n"): line = line[:-1] # skip comments and blank lines XXX what is $ for? - if (line.strip().startswith("#") or - line.strip().startswith("$") or + if (line.strip().startswith(("#", "$")) or line.strip() == ""): continue diff --git a/Lib/difflib.py b/Lib/difflib.py index 55f69ba..39bb2d9 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -1422,8 +1422,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, num_blanks_pending -= 1 yield _make_line(lines,'-',0), None, True continue - elif s.startswith('--?+') or s.startswith('--+') or \ - s.startswith('- '): + elif s.startswith(('--?+', '--+', '- ')): # in delete block and see a intraline change or unchanged line # coming: yield the delete line and then blanks from_line,to_line = _make_line(lines,'-',0), None @@ -1447,7 +1446,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, num_blanks_pending += 1 yield None, _make_line(lines,'+',1), True continue - elif s.startswith('+ ') or s.startswith('+-'): + elif s.startswith(('+ ', '+-')): # will be leaving an add block: yield blanks then add line from_line, to_line = None, _make_line(lines,'+',1) num_blanks_to_yield,num_blanks_pending = num_blanks_pending+1,0 diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 59440f0..7604293 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -649,7 +649,7 @@ class EditorWindow(object): def __extra_help_callback(self, helpfile): "Create a callback with the helpfile value frozen at definition time" def display_extra_help(helpfile=helpfile): - if not (helpfile.startswith('www') or helpfile.startswith('http')): + if not helpfile.startswith(('www', 'http')): url = os.path.normpath(helpfile) if sys.platform[:3] == 'win': os.startfile(helpfile) diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index 191a87c..dcd9321 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -406,7 +406,7 @@ class IdleConf: names=extnNameList kbNameIndicies=[] for name in names: - if name.endswith('_bindings') or name.endswith('_cfgBindings'): + if name.endswith(('_bindings', '_cfgBindings')): kbNameIndicies.append(names.index(name)) kbNameIndicies.sort() kbNameIndicies.reverse() diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/configHelpSourceEdit.py index 8924f79..6611621 100644 --- a/Lib/idlelib/configHelpSourceEdit.py +++ b/Lib/idlelib/configHelpSourceEdit.py @@ -127,7 +127,7 @@ class GetHelpSourceDialog(Toplevel): parent=self) self.entryPath.focus_set() pathOk = False - elif path.startswith('www.') or path.startswith('http'): + elif path.startswith(('www.', 'http')): pass else: if path[:5] == 'file:': @@ -146,8 +146,7 @@ class GetHelpSourceDialog(Toplevel): self.path.get().strip()) if sys.platform == 'darwin': path = self.result[1] - if (path.startswith('www') or path.startswith('file:') - or path.startswith('http:')): + if path.startswith(('www', 'file:', 'http:')): pass else: # Mac Safari insists on using the URI form for local files diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py index 48f1643..6fb20c8 100644 --- a/Lib/test/test_compiler.py +++ b/Lib/test/test_compiler.py @@ -62,7 +62,7 @@ class CompilerTest(unittest.TestCase): def testLineNo(self): # Test that all nodes except Module have a correct lineno attribute. filename = __file__ - if filename.endswith(".pyc") or filename.endswith(".pyo"): + if filename.endswith((".pyc", ".pyo")): filename = filename[:-1] tree = compiler.parseFile(filename) self.check_lineno(tree) diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 79be369..62c40eb 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -15,7 +15,7 @@ from test import inspect_fodder2 as mod2 # isdatadescriptor modfile = mod.__file__ -if modfile.endswith('c') or modfile.endswith('o'): +if modfile.endswith(('c', 'o')): modfile = modfile[:-1] import __builtin__ diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index e3fbf98..fa170ef 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -130,10 +130,8 @@ class TclTest(unittest.TestCase): import os old_display = None import sys - if (sys.platform.startswith('win') or - sys.platform.startswith('darwin') or - sys.platform.startswith('cygwin')): - return # no failure possible on windows? + if sys.platform.startswith(('win', 'darwin', 'cygwin')): + return # no failure possible on windows? if 'DISPLAY' in os.environ: old_display = os.environ['DISPLAY'] del os.environ['DISPLAY'] diff --git a/Lib/trace.py b/Lib/trace.py index ca6294e..db36e1d 100644 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -285,7 +285,7 @@ class CoverageResults: if filename == "<string>": continue - if filename.endswith(".pyc") or filename.endswith(".pyo"): + if filename.endswith((".pyc", ".pyo")): filename = filename[:-1] if coverdir is None: diff --git a/Lib/warnings.py b/Lib/warnings.py index b5d75e4..4b4119d 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -46,7 +46,7 @@ def warn(message, category=None, stacklevel=1): filename = globals.get('__file__') if filename: fnl = filename.lower() - if fnl.endswith(".pyc") or fnl.endswith(".pyo"): + if fnl.endswith((".pyc", ".pyo")): filename = filename[:-1] else: if module == "__main__": diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index 4693fe7..bae0caf 100644 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -98,8 +98,7 @@ def _synthesize(browser, update_tryorder=1): if sys.platform[:3] == "win": def _isexecutable(cmd): cmd = cmd.lower() - if os.path.isfile(cmd) and (cmd.endswith(".exe") or - cmd.endswith(".bat")): + if os.path.isfile(cmd) and cmd.endswith((".exe", ".bat")): return True for ext in ".exe", ".bat": if os.path.isfile(cmd + ext): |