|
5 | 5 | Note: string objects have grown methods in Python 1.6 |
6 | 6 | This module requires Python 1.6 or later. |
7 | 7 | """ |
8 | | -from types import StringType, UnicodeType |
| 8 | +from types import StringTypes |
9 | 9 | import sys |
10 | 10 |
|
11 | 11 | __all__ = ["UserString","MutableString"] |
12 | 12 |
|
13 | 13 | class UserString: |
14 | 14 | def __init__(self, seq): |
15 | | - if isinstance(seq, StringType) or isinstance(seq, UnicodeType): |
| 15 | + if isinstance(seq, StringTypes): |
16 | 16 | self.data = seq |
17 | 17 | elif isinstance(seq, UserString): |
18 | 18 | self.data = seq.data[:] |
@@ -43,19 +43,19 @@ def __getslice__(self, start, end): |
43 | 43 | def __add__(self, other): |
44 | 44 | if isinstance(other, UserString): |
45 | 45 | return self.__class__(self.data + other.data) |
46 | | - elif isinstance(other, StringType) or isinstance(other, UnicodeType): |
| 46 | + elif isinstance(other, StringTypes): |
47 | 47 | return self.__class__(self.data + other) |
48 | 48 | else: |
49 | 49 | return self.__class__(self.data + str(other)) |
50 | 50 | def __radd__(self, other): |
51 | | - if isinstance(other, StringType) or isinstance(other, UnicodeType): |
| 51 | + if isinstance(other, StringTypes): |
52 | 52 | return self.__class__(other + self.data) |
53 | 53 | else: |
54 | 54 | return self.__class__(str(other) + self.data) |
55 | 55 | def __iadd__(self, other): |
56 | 56 | if isinstance(other, UserString): |
57 | 57 | self.data += other.data |
58 | | - elif isinstance(other, StringType) or isinstance(other, UnicodeType): |
| 58 | + elif isinstance(other, StringTypes): |
59 | 59 | self.data += other |
60 | 60 | else: |
61 | 61 | self.data += str(other) |
@@ -159,7 +159,7 @@ def __setslice__(self, start, end, sub): |
159 | 159 | start = max(start, 0); end = max(end, 0) |
160 | 160 | if isinstance(sub, UserString): |
161 | 161 | self.data = self.data[:start]+sub.data+self.data[end:] |
162 | | - elif isinstance(sub, StringType) or isinstance(sub, UnicodeType): |
| 162 | + elif isinstance(sub, StringTypes): |
163 | 163 | self.data = self.data[:start]+sub+self.data[end:] |
164 | 164 | else: |
165 | 165 | self.data = self.data[:start]+str(sub)+self.data[end:] |
|
0 commit comments