summaryrefslogtreecommitdiff
path: root/Lib/UserList.py
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2000-08-24 20:14:10 +0000
committerThomas Wouters <thomas@python.org>2000-08-24 20:14:10 +0000
commit22dc6df1c791c912f3bac3654730f661fa0137ce (patch)
tree00fb3a3d26053939717384de9993c6ebdbb93260 /Lib/UserList.py
parent745303b02734ff69a0c44afff42b44db5875dfe6 (diff)
downloadcpython-22dc6df1c791c912f3bac3654730f661fa0137ce.tar.gz
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.
Diffstat (limited to 'Lib/UserList.py')
-rw-r--r--Lib/UserList.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/UserList.py b/Lib/UserList.py
index d4a8d2f6e4..114606098c 100644
--- a/Lib/UserList.py
+++ b/Lib/UserList.py
@@ -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)