Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bac788a

Browse files
committed
Replace str.find()!=1 with the more readable "in" operator.
1 parent c5e378d commit bac788a

7 files changed

Lines changed: 9 additions & 9 deletions

File tree

Lib/ConfigParser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,15 @@ def _interpolate(self, section, option, rawval, vars):
554554
depth = MAX_INTERPOLATION_DEPTH
555555
while depth: # Loop through this until it's done
556556
depth -= 1
557-
if value.find("%(") != -1:
557+
if "%(" in value:
558558
try:
559559
value = value % vars
560560
except KeyError, e:
561561
raise InterpolationMissingOptionError(
562562
option, section, rawval, e[0])
563563
else:
564564
break
565-
if value.find("%(") != -1:
565+
if "%(" in value:
566566
raise InterpolationDepthError(option, section, rawval)
567567
return value
568568

Lib/_strptime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def pattern(self, format):
250250
format = regex_chars.sub(r"\\\1", format)
251251
whitespace_replacement = re_compile('\s+')
252252
format = whitespace_replacement.sub('\s*', format)
253-
while format.find('%') != -1:
253+
while '%' in format:
254254
directive_index = format.index('%')+1
255255
processed_format = "%s%s%s" % (processed_format,
256256
format[:directive_index-1],

Lib/gettext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def _parse(self, fp):
289289
# cause no problems since us-ascii should always be a subset of
290290
# the charset encoding. We may want to fall back to 8-bit msgids
291291
# if the Unicode conversion fails.
292-
if msg.find('\x00') >= 0:
292+
if '\x00' in msg:
293293
# Plural forms
294294
msgid1, msgid2 = msg.split('\x00')
295295
tmsg = tmsg.split('\x00')

Lib/httplib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _check_close(self):
348348
# An HTTP/1.1 proxy is assumed to stay open unless
349349
# explicitly closed.
350350
conn = self.msg.getheader('connection')
351-
if conn and conn.lower().find("close") >= 0:
351+
if conn and "close" in conn.lower():
352352
return True
353353
return False
354354

@@ -361,7 +361,7 @@ def _check_close(self):
361361

362362
# Proxy-Connection is a netscape hack.
363363
pconn = self.msg.getheader('proxy-connection')
364-
if pconn and pconn.lower().find("keep-alive") >= 0:
364+
if pconn and "keep-alive" in pconn.lower():
365365
return False
366366

367367
# otherwise, assume it will close

Lib/keyword.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def main():
6363
while 1:
6464
line = fp.readline()
6565
if not line: break
66-
if line.find('{1, "') > -1:
66+
if '{1, "' in line:
6767
match = strprog.search(line)
6868
if match:
6969
lines.append(" '" + match.group(1) + "',\n")

Lib/robotparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def applies_to(self, useragent):
214214
# we have the catch-all agent
215215
return True
216216
agent = agent.lower()
217-
if useragent.find(agent) != -1:
217+
if agent in useragent:
218218
return True
219219
return False
220220

Lib/webbrowser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get(using=None):
2222
else:
2323
alternatives = _tryorder
2424
for browser in alternatives:
25-
if browser.find('%s') > -1:
25+
if '%s' in browser:
2626
# User gave us a command line, don't mess with it.
2727
return GenericBrowser(browser)
2828
else:

0 commit comments

Comments
 (0)