|
11 | 11 |
|
12 | 12 | class UserString: |
13 | 13 | def __init__(self, seq): |
14 | | - if isinstance(seq, basestring): |
| 14 | + if isinstance(seq, str): |
15 | 15 | self.data = seq |
16 | 16 | elif isinstance(seq, UserString): |
17 | 17 | self.data = seq.data[:] |
@@ -66,12 +66,12 @@ def __getitem__(self, index): return self.__class__(self.data[index]) |
66 | 66 | def __add__(self, other): |
67 | 67 | if isinstance(other, UserString): |
68 | 68 | return self.__class__(self.data + other.data) |
69 | | - elif isinstance(other, basestring): |
| 69 | + elif isinstance(other, str): |
70 | 70 | return self.__class__(self.data + other) |
71 | 71 | else: |
72 | 72 | return self.__class__(self.data + str(other)) |
73 | 73 | def __radd__(self, other): |
74 | | - if isinstance(other, basestring): |
| 74 | + if isinstance(other, str): |
75 | 75 | return self.__class__(other + self.data) |
76 | 76 | else: |
77 | 77 | return self.__class__(str(other) + self.data) |
@@ -184,7 +184,7 @@ def __setitem__(self, index, sub): |
184 | 184 | if isinstance(index, slice): |
185 | 185 | if isinstance(sub, UserString): |
186 | 186 | sub = sub.data |
187 | | - elif not isinstance(sub, basestring): |
| 187 | + elif not isinstance(sub, str): |
188 | 188 | sub = str(sub) |
189 | 189 | start, stop, step = index.indices(len(self.data)) |
190 | 190 | if step == -1: |
@@ -221,7 +221,7 @@ def immutable(self): |
221 | 221 | def __iadd__(self, other): |
222 | 222 | if isinstance(other, UserString): |
223 | 223 | self.data += other.data |
224 | | - elif isinstance(other, basestring): |
| 224 | + elif isinstance(other, str): |
225 | 225 | self.data += other |
226 | 226 | else: |
227 | 227 | self.data += str(other) |
|
0 commit comments