]> granicus.if.org Git - python/commitdiff
String method cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 10 Feb 2001 00:22:33 +0000 (00:22 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 10 Feb 2001 00:22:33 +0000 (00:22 +0000)
Lib/mhlib.py
Lib/mimify.py
Lib/pre.py
Lib/token.py
Lib/traceback.py

index aab560bb6e33adfdcaf2aff6d5d105e1b12f02aa..0302c30914b65e0703879324e022207a119be610 100644 (file)
@@ -76,7 +76,6 @@ import os
 import sys
 from stat import ST_NLINK
 import re
-import string
 import mimetools
 import multifile
 import shutil
@@ -685,7 +684,7 @@ class Message(mimetools.Message):
         headers = []
         hit = 0
         for line in self.headers:
-            if line[0] not in string.whitespace:
+            if not line[0].isspace():
                 i = line.find(':')
                 if i > 0:
                     hit = pred(line[:i].lower())
@@ -885,7 +884,6 @@ class IntSet:
         self.normalize()
 
     def fromstring(self, data):
-        import string
         new = []
         for part in data.split(self.sep):
             list = []
@@ -918,7 +916,7 @@ def pickline(file, key, casefold = 1):
             text = line[len(key)+1:]
             while 1:
                 line = f.readline()
-                if not line or line[0] not in string.whitespace:
+                if not line or not line[0].isspace():
                     break
                 text = text + line
             return text.strip()
index 64e988bc1d481ea76be8ee3d2780582f14fc8313..c856910b61f645d4e6e19368846e800da8f43669 100755 (executable)
@@ -110,7 +110,7 @@ def mime_decode_header(line):
             break
         match = res.group(1)
         # convert underscores to spaces (before =XX conversion!)
-        match = ' '.join(string.split(match, '_'))
+        match = ' '.join(match.split('_'))
         newline = newline + line[pos:res.start(0)] + mime_decode(match)
         pos = res.end(0)
     return newline + line[pos:]
index c385824f43fe840e73fab03de01631d1c2ca0dc3..35d3e3a9106d3c31cd814e4ed9d42a3054b69206 100644 (file)
@@ -85,7 +85,6 @@ This module also defines an exception 'error'.
 
 
 import sys
-import string
 from pcre import *
 
 #
@@ -223,10 +222,9 @@ def escape(pattern):
 
     """
     result = list(pattern)
-    alphanum=string.letters+'_'+string.digits
     for i in range(len(pattern)):
         char = pattern[i]
-        if char not in alphanum:
+        if not char.isalnum():
             if char=='\000': result[i] = '\\000'
             else: result[i] = '\\'+char
     return ''.join(result)
index 80dc032d0717c380235da77aa6f849b0278e02ab..1c66f6d1cf345db12b19ed94ae413d76b4b5a495 100755 (executable)
@@ -104,7 +104,7 @@ def main():
         match = prog.match(line)
         if match:
             name, val = match.group(1, 2)
-            val = string.atoi(val)
+            val = int(val)
             tokens[val] = name          # reverse so we can sort them...
     keys = tokens.keys()
     keys.sort()
index 834c568dbdcee5c07918bf11e4f841f761542dd0..b4fe05096565515bb8a1e8e13ba0356072cefceb 100644 (file)
@@ -1,7 +1,6 @@
 """Extract, format and print information about Python stack traces."""
 
 import linecache
-import string
 import sys
 import types
 
@@ -154,13 +153,12 @@ def format_exception_only(etype, value):
                 list.append('  File "%s", line %d\n' %
                             (filename, lineno))
                 i = 0
-                while i < len(line) and \
-                      line[i] in string.whitespace:
+                while i < len(line) and line[i].isspace():
                     i = i+1
                 list.append('    %s\n' % line.strip())
                 s = '    '
                 for c in line[i:offset-1]:
-                    if c in string.whitespace:
+                    if c.isspace():
                         s = s + c
                     else:
                         s = s + ' '