Skip to content

Commit 6b71e74

Browse files
String method conversion.
1 parent 141971f commit 6b71e74

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

Lib/CGIHTTPServer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ def is_python(self, path):
103103
def run_cgi(self):
104104
"""Execute a CGI script."""
105105
dir, rest = self.cgi_info
106-
i = string.rfind(rest, '?')
106+
i = rest.rfind('?')
107107
if i >= 0:
108108
rest, query = rest[:i], rest[i+1:]
109109
else:
110110
query = ''
111-
i = string.find(rest, '/')
111+
i = rest.find('/')
112112
if i >= 0:
113113
script, rest = rest[:i], rest[i:]
114114
else:
@@ -165,16 +165,16 @@ def run_cgi(self):
165165
accept = []
166166
for line in self.headers.getallmatchingheaders('accept'):
167167
if line[:1] in string.whitespace:
168-
accept.append(string.strip(line))
168+
accept.append(line.strip())
169169
else:
170-
accept = accept + string.split(line[7:], ',')
171-
env['HTTP_ACCEPT'] = string.joinfields(accept, ',')
170+
accept = accept + line[7:].split(',')
171+
env['HTTP_ACCEPT'] = ','.join(accept)
172172
ua = self.headers.getheader('user-agent')
173173
if ua:
174174
env['HTTP_USER_AGENT'] = ua
175175
co = filter(None, self.headers.getheaders('cookie'))
176176
if co:
177-
env['HTTP_COOKIE'] = string.join(co, ', ')
177+
env['HTTP_COOKIE'] = ', '.join(co)
178178
# XXX Other HTTP_* headers
179179
if not self.have_fork:
180180
# Since we're setting the env in the parent, provide empty
@@ -185,7 +185,7 @@ def run_cgi(self):
185185

186186
self.send_response(200, "Script output follows")
187187

188-
decoded_query = string.replace(query, '+', ' ')
188+
decoded_query = query.replace('+', ' ')
189189

190190
if self.have_fork:
191191
# Unix -- fork as we should

Lib/code.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
import sys
9-
import string
109
import traceback
1110
from codeop import compile_command
1211

@@ -260,7 +259,7 @@ def push(self, line):
260259
261260
"""
262261
self.buffer.append(line)
263-
source = string.join(self.buffer, "\n")
262+
source = "\n".join(self.buffer)
264263
more = self.runsource(source, self.filename)
265264
if not more:
266265
self.resetbuffer()

Lib/codeop.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Utility to compile possibly incomplete Python source code."""
22

33
import sys
4-
import string
54
import traceback
65

76
__all__ = ["compile_command"]
@@ -49,8 +48,8 @@ def compile_command(source, filename="<input>", symbol="single"):
4948
"""
5049

5150
# Check for source consisting of only blank lines and comments
52-
for line in string.split(source, "\n"):
53-
line = string.strip(line)
51+
for line in source.split("\n"):
52+
line = line.strip()
5453
if line and line[0] != '#':
5554
break # Leave it alone
5655
else:

Lib/py_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def compile(file, cfile=None, dfile=None):
5959
try:
6060
codeobject = __builtin__.compile(codestring, dfile or file, 'exec')
6161
except SyntaxError, detail:
62-
import traceback, sys, string
62+
import traceback, sys
6363
lines = traceback.format_exception_only(SyntaxError, detail)
6464
for line in lines:
65-
sys.stderr.write(string.replace(line, 'File "<string>"',
65+
sys.stderr.write(line.replace('File "<string>"',
6666
'File "%s"' % (dfile or file)))
6767
return
6868
if not cfile:

Lib/repr.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Redo the `...` (representation) but with limits on most sizes."""
22

3-
import string
4-
53
class Repr:
64
def __init__(self):
75
self.maxlevel = 6
@@ -16,8 +14,8 @@ def repr(self, x):
1614
def repr1(self, x, level):
1715
typename = `type(x)`[7:-2] # "<type '......'>"
1816
if ' ' in typename:
19-
parts = string.split(typename)
20-
typename = string.joinfields(parts, '_')
17+
parts = typename.split()
18+
typename = '_'.join(parts)
2119
if hasattr(self, 'repr_' + typename):
2220
return getattr(self, 'repr_' + typename)(x, level)
2321
else:

0 commit comments

Comments
 (0)