Mercurial > cpython-lru_cache-weakref
diff Lib/UserString.py @ 14164:dba4aec970e6 legacy-trunk
Support for augmented assignment in the UserList, UserDict, UserString and
rfc822 (Addresslist) modules. Also a preliminary testcase for augmented
assignment, which should actually be merged with the test_class testcase I
added last week.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Thu, 24 Aug 2000 20:14:10 +0000 |
| parents | 3148efe5606f |
| children | 51a33a3b2ba9 |
line wrap: on
line diff
--- a/Lib/UserString.py Thu Aug 24 20:11:32 2000 +0000 +++ b/Lib/UserString.py Thu Aug 24 20:14:10 2000 +0000 @@ -50,9 +50,20 @@ return self.__class__(other + self.data) else: return self.__class__(str(other) + self.data) + def __iadd__(self, other): + if isinstance(other, UserString): + self.data += other.data + elif isinstance(other, StringType) or isinstance(other, UnicodeType): + self.data += other + else + self.data += str(other) + return self def __mul__(self, n): return self.__class__(self.data*n) __rmul__ = __mul__ + def __imull__(self, n): + self.data += n + return self # the following methods are defined in alphabetical order: def capitalize(self): return self.__class__(self.data.capitalize())
