summaryrefslogtreecommitdiffstats
path: root/Lib/UserString.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-06-12 02:07:24 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-06-12 02:07:24 (GMT)
commit418b97eac1bd97c26a02df7a9118a9d08569c46c (patch)
tree034c7e45b39d6ffe5d803eba60f28027d6a31533 /Lib/UserString.py
parent047f3c7ffad1eb30e8b5345d665e3e96062cbd5d (diff)
downloadcpython-418b97eac1bd97c26a02df7a9118a9d08569c46c.zip
cpython-418b97eac1bd97c26a02df7a9118a9d08569c46c.tar.gz
cpython-418b97eac1bd97c26a02df7a9118a9d08569c46c.tar.bz2
Cleanup: Remove import of types to get StringTypes, we can just use basestring.
Diffstat (limited to 'Lib/UserString.py')
-rwxr-xr-xLib/UserString.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/UserString.py b/Lib/UserString.py
index 473ee88..60dc34b 100755
--- a/Lib/UserString.py
+++ b/Lib/UserString.py
@@ -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 @@ class UserString:
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 @@ class MutableString(UserString):
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 @@ class MutableString(UserString):
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)