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

Skip to content

Commit 6e025bc

Browse files
String method cleanup.
1 parent c8c6aa2 commit 6e025bc

5 files changed

Lines changed: 7 additions & 13 deletions

File tree

Lib/mhlib.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
import sys
7777
from stat import ST_NLINK
7878
import re
79-
import string
8079
import mimetools
8180
import multifile
8281
import shutil
@@ -685,7 +684,7 @@ def getheadertext(self, pred = None):
685684
headers = []
686685
hit = 0
687686
for line in self.headers:
688-
if line[0] not in string.whitespace:
687+
if not line[0].isspace():
689688
i = line.find(':')
690689
if i > 0:
691690
hit = pred(line[:i].lower())
@@ -885,7 +884,6 @@ def addpair(self, xlo, xhi):
885884
self.normalize()
886885

887886
def fromstring(self, data):
888-
import string
889887
new = []
890888
for part in data.split(self.sep):
891889
list = []
@@ -918,7 +916,7 @@ def pickline(file, key, casefold = 1):
918916
text = line[len(key)+1:]
919917
while 1:
920918
line = f.readline()
921-
if not line or line[0] not in string.whitespace:
919+
if not line or not line[0].isspace():
922920
break
923921
text = text + line
924922
return text.strip()

Lib/mimify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def mime_decode_header(line):
110110
break
111111
match = res.group(1)
112112
# convert underscores to spaces (before =XX conversion!)
113-
match = ' '.join(string.split(match, '_'))
113+
match = ' '.join(match.split('_'))
114114
newline = newline + line[pos:res.start(0)] + mime_decode(match)
115115
pos = res.end(0)
116116
return newline + line[pos:]

Lib/pre.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585

8686

8787
import sys
88-
import string
8988
from pcre import *
9089

9190
#
@@ -223,10 +222,9 @@ def escape(pattern):
223222
224223
"""
225224
result = list(pattern)
226-
alphanum=string.letters+'_'+string.digits
227225
for i in range(len(pattern)):
228226
char = pattern[i]
229-
if char not in alphanum:
227+
if not char.isalnum():
230228
if char=='\000': result[i] = '\\000'
231229
else: result[i] = '\\'+char
232230
return ''.join(result)

Lib/token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def main():
104104
match = prog.match(line)
105105
if match:
106106
name, val = match.group(1, 2)
107-
val = string.atoi(val)
107+
val = int(val)
108108
tokens[val] = name # reverse so we can sort them...
109109
keys = tokens.keys()
110110
keys.sort()

Lib/traceback.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Extract, format and print information about Python stack traces."""
22

33
import linecache
4-
import string
54
import sys
65
import types
76

@@ -154,13 +153,12 @@ def format_exception_only(etype, value):
154153
list.append(' File "%s", line %d\n' %
155154
(filename, lineno))
156155
i = 0
157-
while i < len(line) and \
158-
line[i] in string.whitespace:
156+
while i < len(line) and line[i].isspace():
159157
i = i+1
160158
list.append(' %s\n' % line.strip())
161159
s = ' '
162160
for c in line[i:offset-1]:
163-
if c in string.whitespace:
161+
if c.isspace():
164162
s = s + c
165163
else:
166164
s = s + ' '

0 commit comments

Comments
 (0)