]> granicus.if.org Git - python/commitdiff
String method conversion.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 9 Feb 2001 08:56:30 +0000 (08:56 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 9 Feb 2001 08:56:30 +0000 (08:56 +0000)
Lib/CGIHTTPServer.py
Lib/code.py
Lib/codeop.py
Lib/py_compile.py
Lib/repr.py

index e2bef264ad36e87663b578910dc566e63dbc58bd..84cdf67068e1948720afdedd1d041cdc7ae2ec1a 100644 (file)
@@ -103,12 +103,12 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
     def run_cgi(self):
         """Execute a CGI script."""
         dir, rest = self.cgi_info
-        i = string.rfind(rest, '?')
+        i = rest.rfind('?')
         if i >= 0:
             rest, query = rest[:i], rest[i+1:]
         else:
             query = ''
-        i = string.find(rest, '/')
+        i = rest.find('/')
         if i >= 0:
             script, rest = rest[:i], rest[i:]
         else:
@@ -165,16 +165,16 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
         accept = []
         for line in self.headers.getallmatchingheaders('accept'):
             if line[:1] in string.whitespace:
-                accept.append(string.strip(line))
+                accept.append(line.strip())
             else:
-                accept = accept + string.split(line[7:], ',')
-        env['HTTP_ACCEPT'] = string.joinfields(accept, ',')
+                accept = accept + line[7:].split(',')
+        env['HTTP_ACCEPT'] = ','.join(accept)
         ua = self.headers.getheader('user-agent')
         if ua:
             env['HTTP_USER_AGENT'] = ua
         co = filter(None, self.headers.getheaders('cookie'))
         if co:
-            env['HTTP_COOKIE'] = string.join(co, ', ')
+            env['HTTP_COOKIE'] = ', '.join(co)
         # XXX Other HTTP_* headers
         if not self.have_fork:
             # Since we're setting the env in the parent, provide empty
@@ -185,7 +185,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
 
         self.send_response(200, "Script output follows")
 
-        decoded_query = string.replace(query, '+', ' ')
+        decoded_query = query.replace('+', ' ')
 
         if self.have_fork:
             # Unix -- fork as we should
index f9d8225d1d581496e8c27692e80af87f47667fdf..ab1050c12e7c6f47864820212cc42ec951c0e3fc 100644 (file)
@@ -6,7 +6,6 @@
 
 
 import sys
-import string
 import traceback
 from codeop import compile_command
 
@@ -260,7 +259,7 @@ class InteractiveConsole(InteractiveInterpreter):
 
         """
         self.buffer.append(line)
-        source = string.join(self.buffer, "\n")
+        source = "\n".join(self.buffer)
         more = self.runsource(source, self.filename)
         if not more:
             self.resetbuffer()
index 46926b58c4c246caf95a31665c1759a2e70ec0a1..3865ec6289930061ef06092a8ed5e1c5581bc456 100644 (file)
@@ -1,7 +1,6 @@
 """Utility to compile possibly incomplete Python source code."""
 
 import sys
-import string
 import traceback
 
 __all__ = ["compile_command"]
@@ -49,8 +48,8 @@ def compile_command(source, filename="<input>", symbol="single"):
     """
 
     # Check for source consisting of only blank lines and comments
-    for line in string.split(source, "\n"):
-        line = string.strip(line)
+    for line in source.split("\n"):
+        line = line.strip()
         if line and line[0] != '#':
             break               # Leave it alone
     else:
index b4531096d71965229970109bbf4d3c2a397ce26c..da3bdafb9694e9f14bfce4cf41e615ddbc6b4adb 100644 (file)
@@ -59,10 +59,10 @@ def compile(file, cfile=None, dfile=None):
     try:
         codeobject = __builtin__.compile(codestring, dfile or file, 'exec')
     except SyntaxError, detail:
-        import traceback, sys, string
+        import traceback, sys
         lines = traceback.format_exception_only(SyntaxError, detail)
         for line in lines:
-            sys.stderr.write(string.replace(line, 'File "<string>"',
+            sys.stderr.write(line.replace('File "<string>"',
                                             'File "%s"' % (dfile or file)))
         return
     if not cfile:
index b47ac2a0beba0db66270df83a7e904e5e10609de..9f7ed86b738070f093380dc5764143dd0eab192e 100644 (file)
@@ -1,7 +1,5 @@
 """Redo the `...` (representation) but with limits on most sizes."""
 
-import string
-
 class Repr:
     def __init__(self):
         self.maxlevel = 6
@@ -16,8 +14,8 @@ class Repr:
     def repr1(self, x, level):
         typename = `type(x)`[7:-2] # "<type '......'>"
         if ' ' in typename:
-            parts = string.split(typename)
-            typename = string.joinfields(parts, '_')
+            parts = typename.split()
+            typename = '_'.join(parts)
         if hasattr(self, 'repr_' + typename):
             return getattr(self, 'repr_' + typename)(x, level)
         else: