summaryrefslogtreecommitdiffstats
path: root/Lib/UserList.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-05-28 22:56:16 (GMT)
committerGuido van Rossum <guido@python.org>1996-05-28 22:56:16 (GMT)
commitce84920e0c1e0b496b8984b0207dce7c8201d02f (patch)
treee535fb6e81f03138edd023b54af017b60bb390fa /Lib/UserList.py
parent48bdbfc1a90131250f88d5e2c570efea4e21f1b8 (diff)
downloadcpython-ce84920e0c1e0b496b8984b0207dce7c8201d02f.zip
cpython-ce84920e0c1e0b496b8984b0207dce7c8201d02f.tar.gz
cpython-ce84920e0c1e0b496b8984b0207dce7c8201d02f.tar.bz2
added * and + operators
Diffstat (limited to 'Lib/UserList.py')
-rw-r--r--Lib/UserList.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/UserList.py b/Lib/UserList.py
index 1c8a622..1f19ad9 100644
--- a/Lib/UserList.py
+++ b/Lib/UserList.py
@@ -28,6 +28,19 @@ class UserList:
else:
self.data[i:j] = list.data
def __delslice__(self, i, j): del self.data[i:j]
+ def __add__(self, list):
+ if type(list) == type(self.data):
+ return self.__class__(self.data + list)
+ else:
+ return self.__class__(self.data + list.data)
+ def __radd__(self, list):
+ if type(list) == type(self.data):
+ return self.__class__(list + self.data)
+ else:
+ return self.__class__(list.data + self.data)
+ def __mul__(self, n):
+ return self.__class__(self.data*n)
+ __rmul__ = __mul__
def append(self, item): self.data.append(item)
def insert(self, i, item): self.data.insert(i, item)
def remove(self, item): self.data.remove(item)