[Python-checkins] r46876 - python/trunk/Lib/UserString.py

neal.norwitz python-checkins at python.org
Mon Jun 12 04:07:24 CEST 2006


Author: neal.norwitz
Date: Mon Jun 12 04:07:24 2006
New Revision: 46876

Modified:
   python/trunk/Lib/UserString.py
Log:
Cleanup: Remove import of types to get StringTypes, we can just use basestring.


Modified: python/trunk/Lib/UserString.py
==============================================================================
--- python/trunk/Lib/UserString.py	(original)
+++ python/trunk/Lib/UserString.py	Mon Jun 12 04:07:24 2006
@@ -5,14 +5,13 @@
 Note: string objects have grown methods in Python 1.6
 This module requires Python 1.6 or later.
 """
-from types import StringTypes
 import sys
 
 __all__ = ["UserString","MutableString"]
 
 class UserString:
     def __init__(self, seq):
-        if isinstance(seq, StringTypes):
+        if isinstance(seq, basestring):
             self.data = seq
         elif isinstance(seq, UserString):
             self.data = seq.data[:]
@@ -43,12 +42,12 @@
     def __add__(self, other):
         if isinstance(other, UserString):
             return self.__class__(self.data + other.data)
-        elif isinstance(other, StringTypes):
+        elif isinstance(other, basestring):
             return self.__class__(self.data + other)
         else:
             return self.__class__(self.data + str(other))
     def __radd__(self, other):
-        if isinstance(other, StringTypes):
+        if isinstance(other, basestring):
             return self.__class__(other + self.data)
         else:
             return self.__class__(str(other) + self.data)
@@ -163,7 +162,7 @@
         start = max(start, 0); end = max(end, 0)
         if isinstance(sub, UserString):
             self.data = self.data[:start]+sub.data+self.data[end:]
-        elif isinstance(sub, StringTypes):
+        elif isinstance(sub, basestring):
             self.data = self.data[:start]+sub+self.data[end:]
         else:
             self.data =  self.data[:start]+str(sub)+self.data[end:]
@@ -175,7 +174,7 @@
     def __iadd__(self, other):
         if isinstance(other, UserString):
             self.data += other.data
-        elif isinstance(other, StringTypes):
+        elif isinstance(other, basestring):
             self.data += other
         else:
             self.data += str(other)


More information about the Python-checkins mailing list