]> granicus.if.org Git - python/commitdiff
added * and + operators
authorGuido van Rossum <guido@python.org>
Tue, 28 May 1996 22:56:16 +0000 (22:56 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 28 May 1996 22:56:16 +0000 (22:56 +0000)
Lib/UserList.py

index 1c8a622a241de8dcdfa10d910e89a9618cd95b35..1f19ad9c466f7f349523a59b7a6b0b641470cea0 100644 (file)
@@ -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)