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

Skip to content

Commit b49f4a4

Browse files
String method conversion.
1 parent 20e4423 commit b49f4a4

5 files changed

Lines changed: 13 additions & 20 deletions

File tree

Lib/BaseHTTPServer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import sys
6969
import time
7070
import socket # For gethostbyaddr()
71-
import string
7271
import mimetools
7372
import SocketServer
7473

@@ -203,7 +202,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
203202
"""
204203

205204
# The Python system version, truncated to its first component.
206-
sys_version = "Python/" + string.split(sys.version)[0]
205+
sys_version = "Python/" + sys.version.split()[0]
207206

208207
# The server software version. You may want to override this.
209208
# The format is multiple whitespace-separated strings,
@@ -228,7 +227,7 @@ def parse_request(self):
228227
elif requestline[-1:] == '\n':
229228
requestline = requestline[:-1]
230229
self.requestline = requestline
231-
words = string.split(requestline)
230+
words = requestline.split()
232231
if len(words) == 3:
233232
[command, path, version] = words
234233
if version[:5] != 'HTTP/':
@@ -468,7 +467,7 @@ def test(HandlerClass = BaseHTTPRequestHandler,
468467
"""
469468

470469
if sys.argv[1:]:
471-
port = string.atoi(sys.argv[1])
470+
port = sys.argv[1].atoi()
472471
else:
473472
port = 8000
474473
server_address = ('', port)

Lib/asynchat.py

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

4949
import socket
5050
import asyncore
51-
import string
5251

5352
class async_chat (asyncore.dispatcher):
5453
"""This is an abstract class. You must derive from this class, and add
@@ -120,7 +119,7 @@ def handle_read (self):
120119
# 3) end of buffer does not match any prefix:
121120
# collect data
122121
terminator_len = len(terminator)
123-
index = string.find (self.ac_in_buffer, terminator)
122+
index = terminator.find (self.ac_in_buffer)
124123
if index != -1:
125124
# we found the terminator
126125
if index > 0:

Lib/asyncore.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import exceptions
5050
import select
5151
import socket
52-
import string
5352
import sys
5453

5554
import os
@@ -219,7 +218,7 @@ def __repr__ (self):
219218
status.append ('%s:%d' % self.addr)
220219
return '<%s %s at %x>' % (
221220
self.__class__.__name__,
222-
string.join (status, ' '),
221+
' '.join (status),
223222
id(self)
224223
)
225224
except:
@@ -480,13 +479,7 @@ def compact_traceback ():
480479
del tb
481480

482481
file, function, line = tbinfo[-1]
483-
info = '[' + string.join (
484-
map (
485-
lambda x: string.join (x, '|'),
486-
tbinfo
487-
),
488-
'] ['
489-
) + ']'
482+
info = '[' + '] ['.join(map(lambda x: '|'.join(x), tbinfo)) + ']'
490483
return (file, function, line), t, v, info
491484

492485
def close_all (map=None):

Lib/bdb.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def get_stack(self, f, t):
306306
#
307307

308308
def format_stack_entry(self, frame_lineno, lprefix=': '):
309-
import linecache, repr, string
309+
import linecache, repr
310310
frame, lineno = frame_lineno
311311
filename = self.canonic(frame.f_code.co_filename)
312312
s = filename + '(' + `lineno` + ')'
@@ -327,7 +327,7 @@ def format_stack_entry(self, frame_lineno, lprefix=': '):
327327
s = s + '->'
328328
s = s + repr.repr(rv)
329329
line = linecache.getline(filename, lineno)
330-
if line: s = s + lprefix + string.strip(line)
330+
if line: s = s + lprefix + line.strip()
331331
return s
332332

333333
# The following two methods can be called by clients to use
@@ -534,12 +534,12 @@ def user_call(self, frame, args):
534534
if not name: name = '???'
535535
print '+++ call', name, args
536536
def user_line(self, frame):
537-
import linecache, string
537+
import linecache
538538
name = frame.f_code.co_name
539539
if not name: name = '???'
540540
fn = self.canonic(frame.f_code.co_filename)
541541
line = linecache.getline(fn, frame.f_lineno)
542-
print '+++', fn, frame.f_lineno, name, ':', string.strip(line)
542+
print '+++', fn, frame.f_lineno, name, ':', line.strip()
543543
def user_return(self, frame, retval):
544544
print '+++ return', retval
545545
def user_exception(self, frame, exc_stuff):
@@ -558,3 +558,5 @@ def bar(a):
558558
def test():
559559
t = Tdb()
560560
t.run('import bdb; bdb.foo(10)')
561+
562+
# end

Lib/binhex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def getfileinfo(name):
102102
dsize = fp.tell()
103103
fp.close()
104104
dir, file = os.path.split(name)
105-
file = string.replace(file, ':', '-', 1)
105+
file = file.replace(':', '-', 1)
106106
return file, finfo, dsize, 0
107107

108108
class openrsrc:

0 commit comments

Comments
 (0)