summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-05-04 09:21:43 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-05-04 09:21:43 (GMT)
commitbac788a3cd348203a5fdabba52e5faf65bf35c5e (patch)
tree3c5bfe8295936ad51df617ef0fd053ebac684357
parentc5e378da41641d5bc1e9b5c6c11bd470ff90b3e3 (diff)
downloadcpython-bac788a3cd348203a5fdabba52e5faf65bf35c5e.zip
cpython-bac788a3cd348203a5fdabba52e5faf65bf35c5e.tar.gz
cpython-bac788a3cd348203a5fdabba52e5faf65bf35c5e.tar.bz2
Replace str.find()!=1 with the more readable "in" operator.
-rw-r--r--Lib/ConfigParser.py4
-rw-r--r--Lib/_strptime.py2
-rw-r--r--Lib/gettext.py2
-rw-r--r--Lib/httplib.py4
-rwxr-xr-xLib/keyword.py2
-rw-r--r--Lib/robotparser.py2
-rw-r--r--Lib/webbrowser.py2
7 files changed, 9 insertions, 9 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py
index e12717d..d32eae0 100644
--- a/Lib/ConfigParser.py
+++ b/Lib/ConfigParser.py
@@ -554,7 +554,7 @@ class ConfigParser(RawConfigParser):
depth = MAX_INTERPOLATION_DEPTH
while depth: # Loop through this until it's done
depth -= 1
- if value.find("%(") != -1:
+ if "%(" in value:
try:
value = value % vars
except KeyError, e:
@@ -562,7 +562,7 @@ class ConfigParser(RawConfigParser):
option, section, rawval, e[0])
else:
break
- if value.find("%(") != -1:
+ if "%(" in value:
raise InterpolationDepthError(option, section, rawval)
return value
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index 361f52e..22455ae 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -250,7 +250,7 @@ class TimeRE(dict):
format = regex_chars.sub(r"\\\1", format)
whitespace_replacement = re_compile('\s+')
format = whitespace_replacement.sub('\s*', format)
- while format.find('%') != -1:
+ while '%' in format:
directive_index = format.index('%')+1
processed_format = "%s%s%s" % (processed_format,
format[:directive_index-1],
diff --git a/Lib/gettext.py b/Lib/gettext.py
index ed9d3ea..920aa46 100644
--- a/Lib/gettext.py
+++ b/Lib/gettext.py
@@ -289,7 +289,7 @@ class GNUTranslations(NullTranslations):
# cause no problems since us-ascii should always be a subset of
# the charset encoding. We may want to fall back to 8-bit msgids
# if the Unicode conversion fails.
- if msg.find('\x00') >= 0:
+ if '\x00' in msg:
# Plural forms
msgid1, msgid2 = msg.split('\x00')
tmsg = tmsg.split('\x00')
diff --git a/Lib/httplib.py b/Lib/httplib.py
index a23caf5..40e78b0 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -348,7 +348,7 @@ class HTTPResponse:
# An HTTP/1.1 proxy is assumed to stay open unless
# explicitly closed.
conn = self.msg.getheader('connection')
- if conn and conn.lower().find("close") >= 0:
+ if conn and "close" in conn.lower():
return True
return False
@@ -361,7 +361,7 @@ class HTTPResponse:
# Proxy-Connection is a netscape hack.
pconn = self.msg.getheader('proxy-connection')
- if pconn and pconn.lower().find("keep-alive") >= 0:
+ if pconn and "keep-alive" in pconn.lower():
return False
# otherwise, assume it will close
diff --git a/Lib/keyword.py b/Lib/keyword.py
index a0295e2..223a88a 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -63,7 +63,7 @@ def main():
while 1:
line = fp.readline()
if not line: break
- if line.find('{1, "') > -1:
+ if '{1, "' in line:
match = strprog.search(line)
if match:
lines.append(" '" + match.group(1) + "',\n")
diff --git a/Lib/robotparser.py b/Lib/robotparser.py
index 6b23188..13d8ac2 100644
--- a/Lib/robotparser.py
+++ b/Lib/robotparser.py
@@ -214,7 +214,7 @@ class Entry:
# we have the catch-all agent
return True
agent = agent.lower()
- if useragent.find(agent) != -1:
+ if agent in useragent:
return True
return False
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index cb9dbb3..f8b41e5 100644
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -22,7 +22,7 @@ def get(using=None):
else:
alternatives = _tryorder
for browser in alternatives:
- if browser.find('%s') > -1:
+ if '%s' in browser:
# User gave us a command line, don't mess with it.
return GenericBrowser(browser)
else: