Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bac788a3
Commit
bac788a3
authored
May 04, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace str.find()!=1 with the more readable "in" operator.
parent
c5e378da
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
9 additions
and
9 deletions
+9
-9
Lib/ConfigParser.py
Lib/ConfigParser.py
+2
-2
Lib/_strptime.py
Lib/_strptime.py
+1
-1
Lib/gettext.py
Lib/gettext.py
+1
-1
Lib/httplib.py
Lib/httplib.py
+2
-2
Lib/keyword.py
Lib/keyword.py
+1
-1
Lib/robotparser.py
Lib/robotparser.py
+1
-1
Lib/webbrowser.py
Lib/webbrowser.py
+1
-1
No files found.
Lib/ConfigParser.py
View file @
bac788a3
...
@@ -554,7 +554,7 @@ class ConfigParser(RawConfigParser):
...
@@ -554,7 +554,7 @@ class ConfigParser(RawConfigParser):
depth = MAX_INTERPOLATION_DEPTH
depth = MAX_INTERPOLATION_DEPTH
while depth: # Loop through this until it's done
while depth: # Loop through this until it's done
depth -= 1
depth -= 1
if
value.find("%(") != -1
:
if
"%(" in value
:
try:
try:
value = value % vars
value = value % vars
except KeyError, e:
except KeyError, e:
...
@@ -562,7 +562,7 @@ class ConfigParser(RawConfigParser):
...
@@ -562,7 +562,7 @@ class ConfigParser(RawConfigParser):
option, section, rawval, e[0])
option, section, rawval, e[0])
else:
else:
break
break
if
value.find("%(") != -1
:
if
"%(" in value
:
raise InterpolationDepthError(option, section, rawval)
raise InterpolationDepthError(option, section, rawval)
return value
return value
...
...
Lib/_strptime.py
View file @
bac788a3
...
@@ -250,7 +250,7 @@ class TimeRE(dict):
...
@@ -250,7 +250,7 @@ class TimeRE(dict):
format
=
regex_chars
.
sub
(
r"\\\1"
,
format
)
format
=
regex_chars
.
sub
(
r"\\\1"
,
format
)
whitespace_replacement
=
re_compile
(
'
\
s+
'
)
whitespace_replacement
=
re_compile
(
'
\
s+
'
)
format = whitespace_replacement.sub('
\
s
*
', format)
format = whitespace_replacement.sub('
\
s
*
', format)
while
format.find('
%
') != -1
:
while
'
%
' in format
:
directive_index = format.index('
%
')+1
directive_index = format.index('
%
')+1
processed_format = "%s%s%s" % (processed_format,
processed_format = "%s%s%s" % (processed_format,
format[:directive_index-1],
format[:directive_index-1],
...
...
Lib/gettext.py
View file @
bac788a3
...
@@ -289,7 +289,7 @@ class GNUTranslations(NullTranslations):
...
@@ -289,7 +289,7 @@ class GNUTranslations(NullTranslations):
# cause no problems since us-ascii should always be a subset of
# 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
# the charset encoding. We may want to fall back to 8-bit msgids
# if the Unicode conversion fails.
# if the Unicode conversion fails.
if
msg
.
find
(
'
\
x00
'
)
>=
0
:
if
'
\
x00
'
in
msg
:
# Plural forms
# Plural forms
msgid1
,
msgid2
=
msg
.
split
(
'
\
x00
'
)
msgid1
,
msgid2
=
msg
.
split
(
'
\
x00
'
)
tmsg
=
tmsg
.
split
(
'
\
x00
'
)
tmsg
=
tmsg
.
split
(
'
\
x00
'
)
...
...
Lib/httplib.py
View file @
bac788a3
...
@@ -348,7 +348,7 @@ class HTTPResponse:
...
@@ -348,7 +348,7 @@ class HTTPResponse:
# An HTTP/1.1 proxy is assumed to stay open unless
# An HTTP/1.1 proxy is assumed to stay open unless
# explicitly closed.
# explicitly closed.
conn
=
self
.
msg
.
getheader
(
'connection'
)
conn
=
self
.
msg
.
getheader
(
'connection'
)
if
conn
and
conn
.
lower
().
find
(
"close"
)
>=
0
:
if
conn
and
"close"
in
conn
.
lower
()
:
return
True
return
True
return
False
return
False
...
@@ -361,7 +361,7 @@ class HTTPResponse:
...
@@ -361,7 +361,7 @@ class HTTPResponse:
# Proxy-Connection is a netscape hack.
# Proxy-Connection is a netscape hack.
pconn
=
self
.
msg
.
getheader
(
'proxy-connection'
)
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
return
False
# otherwise, assume it will close
# otherwise, assume it will close
...
...
Lib/keyword.py
View file @
bac788a3
...
@@ -63,7 +63,7 @@ def main():
...
@@ -63,7 +63,7 @@ def main():
while
1
:
while
1
:
line
=
fp
.
readline
()
line
=
fp
.
readline
()
if
not
line
:
break
if
not
line
:
break
if
line
.
find
(
'{1, "'
)
>
-
1
:
if
'{1, "'
in
line
:
match
=
strprog
.
search
(
line
)
match
=
strprog
.
search
(
line
)
if
match
:
if
match
:
lines
.
append
(
" '"
+
match
.
group
(
1
)
+
"',
\
n
"
)
lines
.
append
(
" '"
+
match
.
group
(
1
)
+
"',
\
n
"
)
...
...
Lib/robotparser.py
View file @
bac788a3
...
@@ -214,7 +214,7 @@ class Entry:
...
@@ -214,7 +214,7 @@ class Entry:
# we have the catch-all agent
# we have the catch-all agent
return
True
return
True
agent
=
agent
.
lower
()
agent
=
agent
.
lower
()
if
useragent
.
find
(
agent
)
!=
-
1
:
if
agent
in
useragent
:
return
True
return
True
return
False
return
False
...
...
Lib/webbrowser.py
View file @
bac788a3
...
@@ -22,7 +22,7 @@ def get(using=None):
...
@@ -22,7 +22,7 @@ def get(using=None):
else
:
else
:
alternatives
=
_tryorder
alternatives
=
_tryorder
for
browser
in
alternatives
:
for
browser
in
alternatives
:
if
browser
.
find
(
'%s'
)
>
-
1
:
if
'%s'
in
browser
:
# User gave us a command line, don't mess with it.
# User gave us a command line, don't mess with it.
return
GenericBrowser
(
browser
)
return
GenericBrowser
(
browser
)
else
:
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment