Martin von Löwis <martin@loewis.home.cs.tu-berlin.de>:
This patch delegates more string functions to string object methods,
uses the varargs delegation syntax, and stops using stringold.

Closes SourceForge patch #100712.
diff --git a/Lib/string.py b/Lib/string.py
index 5f90723..21781e7 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -125,9 +125,6 @@
     return sep.join(words)
 joinfields = join
 
-# for a little bit of speed
-_apply = apply
-
 # Find substring, raise exception if not found
 def index(s, *args):
     """index(s, sub [,start [,end]]) -> int
@@ -135,7 +132,7 @@
     Like find but raises ValueError when the substring is not found.
 
     """
-    return _apply(s.index, args)
+    return s.index(*args)
 
 # Find last substring, raise exception if not found
 def rindex(s, *args):
@@ -144,7 +141,7 @@
     Like rfind but raises ValueError when the substring is not found.
 
     """
-    return _apply(s.rindex, args)
+    return s.rindex(*args)
 
 # Count non-overlapping occurrences of substring
 def count(s, *args):
@@ -155,7 +152,7 @@
     interpreted as in slice notation.
 
     """
-    return _apply(s.count, args)
+    return s.count(*args)
 
 # Find substring, return -1 if not found
 def find(s, *args):
@@ -168,7 +165,7 @@
     Return -1 on failure.
 
     """
-    return _apply(s.find, args)
+    return s.find(*args)
 
 # Find last substring, return -1 if not found
 def rfind(s, *args):
@@ -181,7 +178,7 @@
     Return -1 on failure.
 
     """
-    return _apply(s.rfind, args)
+    return s.rfind(*args)
 
 # for a bit of speed
 _float = float
@@ -239,9 +236,7 @@
     never truncated.
 
     """
-    n = width - len(s)
-    if n <= 0: return s
-    return s + ' '*n
+    return s.ljust(width)
 
 # Right-justify a string
 def rjust(s, width):
@@ -252,9 +247,7 @@
     never truncated.
 
     """
-    n = width - len(s)
-    if n <= 0: return s
-    return ' '*n + s
+    return s.rjust(width)
 
 # Center a string
 def center(s, width):
@@ -265,13 +258,7 @@
     truncated.
 
     """
-    n = width - len(s)
-    if n <= 0: return s
-    half = n/2
-    if n%2 and width%2:
-        # This ensures that center(center(s, i), j) = center(s, j)
-        half = half+1
-    return ' '*half +  s + ' '*(n-half)
+    return s.center(width)
 
 # Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03'
 # Decadent feature: the argument may be a string or a number
@@ -302,15 +289,7 @@
     column, and the tabsize (default 8).
 
     """
-    res = line = ''
-    for c in s:
-        if c == '\t':
-            c = ' '*(tabsize - len(line) % tabsize)
-        line = line + c
-        if c == '\n':
-            res = res + line
-            line = ''
-    return res + line
+    return s.expandtabs(tabsize)
 
 # Character translation through look-up table.
 def translate(s, table, deletions=""):
@@ -380,16 +359,6 @@
     return s.replace(old, new, maxsplit)
 
 
-# XXX: transitional
-#
-# If string objects do not have methods, then we need to use the old string.py
-# library, which uses strop for many more things than just the few outlined
-# below.
-try:
-    ''.upper
-except AttributeError:
-    from stringold import *
-
 # Try importing optional built-in module "strop" -- if it exists,
 # it redefines some string operations that are 100-1000 times faster.
 # It also defines values for whitespace, lowercase and uppercase