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.
This commit is contained in:
Thomas Wouters 2000-08-24 20:14:10 +00:00
parent 434d0828d8
commit 104a7bcc28
6 changed files with 327 additions and 1 deletions

View file

@ -51,9 +51,20 @@ class UserList:
return self.__class__(other + self.data)
else:
return self.__class__(list(other) + self.data)
def __iadd__(self, other):
if isinstance(other, UserList):
self.data += other.data
elif isinstance(other, type(self.data)):
self.data += other
else:
self.data += list(other)
return self
def __mul__(self, n):
return self.__class__(self.data*n)
__rmul__ = __mul__
def __imul__(self, n):
self.data *= n
return self
def append(self, item): self.data.append(item)
def insert(self, i, item): self.data.insert(i, item)
def pop(self, i=-1): return self.data.pop(i)