Skip to content

Commit fc170b1

Browse files
String method conversion.
1 parent d8c628b commit fc170b1

File tree

19 files changed

+58
-79
lines changed

19 files changed

+58
-79
lines changed

Lib/distutils/cmd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
__revision__ = "$Id$"
1111

12-
import sys, os, string, re
12+
import sys, os, re
1313
from types import *
1414
from distutils.errors import *
1515
from distutils import util, dir_util, file_util, archive_util, dep_util
@@ -161,7 +161,7 @@ def dump_options (self, header=None, indent=""):
161161
print indent + header
162162
indent = indent + " "
163163
for (option, _, _) in self.user_options:
164-
option = string.translate(option, longopt_xlate)
164+
option = option.translate(longopt_xlate)
165165
if option[-1] == "=":
166166
option = option[:-1]
167167
value = getattr(self, option)
@@ -421,7 +421,7 @@ def make_file (self, infiles, outfile, func, args,
421421
"""
422422
if exec_msg is None:
423423
exec_msg = "generating %s from %s" % \
424-
(outfile, string.join(infiles, ', '))
424+
(outfile, ', '.join(infiles))
425425
if skip_msg is None:
426426
skip_msg = "skipping %s (inputs unchanged)" % outfile
427427

Lib/lib-old/codehack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def getcodename(co):
4848
if ord(code[0]) == SET_LINENO:
4949
lineno = ord(code[1]) | ord(code[2]) << 8
5050
line = linecache.getline(filename, lineno)
51-
words = string.split(line)
51+
words = line.split()
5252
if len(words) >= 2 and words[0] in ('def', 'class'):
5353
name = words[1]
5454
for i in range(len(name)):

Lib/lib-old/grep.py

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

33
import regex
44
from regex_syntax import *
5-
import string
65

76
opt_show_where = 0
87
opt_show_filename = 0
@@ -59,7 +58,7 @@ def pgrep(pat, *files):
5958
def showline(filename, lineno, line, prog):
6059
if line[-1:] == '\n': line = line[:-1]
6160
if opt_show_lineno:
62-
prefix = string.rjust(`lineno`, 3) + ': '
61+
prefix = `lineno`.rjust(, 3) + ': '
6362
else:
6463
prefix = ''
6564
if opt_show_filename:

Lib/lib-old/ni.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@
163163

164164

165165
import imp
166-
import string
167166
import sys
168167
import __builtin__
169168

@@ -206,7 +205,7 @@ def load_module(self, name, stuff):
206205
def load_dynamic(self, name, stuff):
207206
file, filename, (suff, mode, type) = stuff
208207
# Hack around restriction in imp.load_dynamic()
209-
i = string.rfind(name, '.')
208+
i = name.rfind('.')
210209
tail = name[i+1:]
211210
if sys.modules.has_key(tail):
212211
save = sys.modules[tail]
@@ -241,7 +240,7 @@ def init_package(self, package):
241240
def set_parent(self, m):
242241
name = m.__name__
243242
if '.' in name:
244-
name = name[:string.rfind(name, '.')]
243+
name = name[:name.rfind('.')]
245244
else:
246245
name = ''
247246
m.__ = sys.modules[name]
@@ -250,7 +249,7 @@ def set_domain(self, package):
250249
name = package.__name__
251250
package.__domain__ = domain = [name]
252251
while '.' in name:
253-
name = name[:string.rfind(name, '.')]
252+
name = name[:name.rfind('.')]
254253
domain.append(name)
255254
if name:
256255
domain.append('')
@@ -285,15 +284,15 @@ def import_module(self, name, globals={}, locals={}, fromlist=[]):
285284
if not name:
286285
return self.finish(package, p, '', fromlist)
287286
if '.' in name:
288-
i = string.find(name, '.')
287+
i = name.find('.')
289288
name, tail = name[:i], name[i:]
290289
else:
291290
tail = ''
292291
mname = p.__name__ and p.__name__+'.'+name or name
293292
m = self.get1(mname)
294293
return self.finish(package, m, tail, fromlist)
295294
if '.' in name:
296-
i = string.find(name, '.')
295+
i = name.find('.')
297296
name, tail = name[:i], name[i:]
298297
else:
299298
tail = ''
@@ -312,7 +311,7 @@ def finish(self, module, m, tail, fromlist):
312311
yname, tail = yname + tail, ''
313312
m = self.get1(yname)
314313
while tail:
315-
i = string.find(tail, '.', 1)
314+
i = tail.find('.', 1)
316315
if i > 0:
317316
head, tail = tail[:i], tail[i:]
318317
else:
@@ -351,7 +350,7 @@ def get(self, name):
351350
if sys.modules.has_key(name):
352351
return sys.modules[name]
353352
if '.' in name:
354-
i = string.rfind(name, '.')
353+
i = name.rfind('.')
355354
head, tail = name[:i], name[i+1:]
356355
else:
357356
head, tail = '', name
@@ -367,7 +366,7 @@ def get(self, name):
367366
def reload(self, module):
368367
name = module.__name__
369368
if '.' in name:
370-
i = string.rfind(name, '.')
369+
i = name.rfind('.')
371370
head, tail = name[:i], name[i+1:]
372371
path = sys.modules[head].__path__
373372
else:

Lib/lib-old/packmail.py

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

66
import os
77
from stat import ST_MTIME
8-
import string
98

109
# Print help
1110
def help():
@@ -103,7 +102,7 @@ def packtree(outfp, dirname):
103102
packtree(outfp, subdirname)
104103

105104
def unixfix(name):
106-
comps = string.splitfields(name, os.sep)
105+
comps = name.splitfields(os.sep)
107106
res = ''
108107
for comp in comps:
109108
if comp:

Lib/lib-old/tb.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
import os
77
from stat import *
8-
import string
98
import linecache
109

1110
def br(): browser(sys.last_traceback)
@@ -35,7 +34,7 @@ def browser(tb):
3534
except EOFError:
3635
print '\n[EOF]'
3736
break
38-
cmd = string.strip(line)
37+
cmd = line.strip()
3938
if cmd:
4039
if cmd == 'quit':
4140
break
@@ -62,8 +61,8 @@ def browserlist(tb):
6261
last = lineno
6362
first = max(1, last-10)
6463
for i in range(first, last+1):
65-
if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':'
66-
else: prefix = string.rjust(`i`, 7) + ':'
64+
if i == lineno: prefix = '***' + `i`.rjust(4) + ':'
65+
else: prefix = `i`.rjust(7) + ':'
6766
line = linecache.getline(filename, i)
6867
if line[-1:] == '\n': line = line[:-1]
6968
print prefix + line
@@ -115,14 +114,14 @@ def printtbheader(tb):
115114
info = '"' + filename + '"(' + `lineno` + ')'
116115
line = linecache.getline(filename, lineno)
117116
if line:
118-
info = info + ': ' + string.strip(line)
117+
info = info + ': ' + line.strip()
119118
print info
120119

121120
def printsymbols(d):
122121
keys = d.keys()
123122
keys.sort()
124123
for name in keys:
125-
print ' ' + string.ljust(name, 12) + ':',
124+
print ' ' + name.ljust(12) + ':',
126125
printobject(d[name], 4)
127126
print
128127

Lib/lib-tk/Tkinter.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@
3737
TclError = _tkinter.TclError
3838
from types import *
3939
from Tkconstants import *
40-
import string; _string = string; del string
4140
try:
4241
import MacOS; _MacOS = MacOS; del MacOS
4342
except ImportError:
4443
_MacOS = None
4544

46-
TkVersion = _string.atof(_tkinter.TK_VERSION)
47-
TclVersion = _string.atof(_tkinter.TCL_VERSION)
45+
TkVersion = float(_tkinter.TK_VERSION)
46+
TclVersion = float(_tkinter.TCL_VERSION)
4847

4948
READABLE = _tkinter.READABLE
5049
WRITABLE = _tkinter.WRITABLE
@@ -782,7 +781,7 @@ def __winfo_parseitem(self, t):
782781
return t[:1] + tuple(map(self.__winfo_getint, t[1:]))
783782
def __winfo_getint(self, x):
784783
"""Internal function."""
785-
return _string.atoi(x, 0)
784+
return int(x, 0)
786785
def winfo_vrootheight(self):
787786
"""Return the height of the virtual root window associated with this
788787
widget in pixels. If there is no virtual root window return the
@@ -850,7 +849,7 @@ def _bind(self, what, sequence, func, add, needcleanup=1):
850849
%
851850
(add and '+' or '',
852851
funcid,
853-
_string.join(self._subst_format)))
852+
" ".join(self._subst_format)))
854853
self.tk.call(what + (sequence, cmd))
855854
return funcid
856855
elif sequence:
@@ -972,9 +971,8 @@ def nametowidget(self, name):
972971
if name[0] == '.':
973972
w = w._root()
974973
name = name[1:]
975-
find = _string.find
976974
while name:
977-
i = find(name, '.')
975+
i = name.find('.')
978976
if i >= 0:
979977
name, tail = name[:i], name[i+1:]
980978
else:

Lib/lib-tk/tkFont.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
__version__ = "0.9"
1919

2020
import Tkinter
21-
import string
2221

2322
# weight/slant
2423
NORMAL = "normal"
@@ -120,7 +119,7 @@ def config(self, **options):
120119

121120
def measure(self, text):
122121
"Return text width"
123-
return string.atoi(self._call("font", "measure", self.name, text))
122+
return int(self._call("font", "measure", self.name, text))
124123

125124
def metrics(self, *options):
126125
"""Return font metrics.
@@ -129,14 +128,14 @@ def metrics(self, *options):
129128
using this font before calling this method."""
130129

131130
if options:
132-
return string.atoi(
131+
return int(
133132
self._call("font", "metrics", self.name, self._get(options))
134133
)
135134
else:
136135
res = self._split(self._call("font", "metrics", self.name))
137136
options = {}
138137
for i in range(0, len(res), 2):
139-
options[res[i][1:]] = string.atoi(res[i+1])
138+
options[res[i][1:]] = int(res[i+1])
140139
return options
141140

142141
def families(root=None):

Lib/lib-tk/tkSimpleDialog.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ def apply(self):
157157
# --------------------------------------------------------------------
158158
# convenience dialogues
159159

160-
import string
161-
162160
class _QueryDialog(Dialog):
163161

164162
def __init__(self, title, prompt,
@@ -236,7 +234,7 @@ def validate(self):
236234
class _QueryInteger(_QueryDialog):
237235
errormessage = "Not an integer."
238236
def getresult(self):
239-
return string.atoi(self.entry.get())
237+
return int(self.entry.get())
240238

241239
def askinteger(title, prompt, **kw):
242240
'''get an integer from the user
@@ -255,7 +253,7 @@ def askinteger(title, prompt, **kw):
255253
class _QueryFloat(_QueryDialog):
256254
errormessage = "Not a floating point value."
257255
def getresult(self):
258-
return string.atof(self.entry.get())
256+
return float(self.entry.get())
259257

260258
def askfloat(title, prompt, **kw):
261259
'''get a float from the user

0 commit comments

Comments
 (0)