]> granicus.if.org Git - python/commitdiff
Replace str.find()!=1 with the more readable "in" operator.
authorRaymond Hettinger <python@rcn.com>
Tue, 4 May 2004 09:21:43 +0000 (09:21 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 4 May 2004 09:21:43 +0000 (09:21 +0000)
Lib/ConfigParser.py
Lib/_strptime.py
Lib/gettext.py
Lib/httplib.py
Lib/keyword.py
Lib/robotparser.py
Lib/webbrowser.py

index e12717dbf00d57834387d2834d773ea717b9c6f2..d32eae03298fea11eee898cc211b86689b31ed84 100644 (file)
@@ -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
 
index 361f52e2dd96d8458e21d2592f88420f2f57ba30..22455ae9934c3ddd94143123da5494dd2baaf2d7 100644 (file)
@@ -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],
index ed9d3ea990e49e4b771b1344dddb2603bddd1cf8..920aa4642ab90ca05ba2f4be5aaeba3f333702f6 100644 (file)
@@ -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')
index a23caf5651c689d73994d7b1df659491d18b827f..40e78b0fafed2a2498f5210646ec8f8148e26596 100644 (file)
@@ -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
index a0295e2139e916056a9e0c38f465a4ce564b908a..223a88a9deace1803bce79cf5d590508f259e711 100755 (executable)
@@ -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")
index 6b23188f196e0e9420ed8d1d15c2e82bc9d45a48..13d8ac2528cc17e484af3fad3966aeddd64dde64 100644 (file)
@@ -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
 
index cb9dbb36bd8a6b77d63f1fc9eaf3f7688cc848d5..f8b41e537c4acb54104a64ed629a46d3e0518ff5 100644 (file)
@@ -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: