if one explitely initializes UserList in a class derived
form Userlist, __getslice__, __*add__ and __mul__ do not
work.
Consider the following code:
>>> import UserList
>>> class UL(UserList.UserList):
... def __init__(self):
... UserList.UserList.__init__(self)
...
>>> ul=UL()
>>> ul.append(0); ul.append(1)
>>> ul[0:2]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "hd e18 yosi:programs:programing:python
2.0c1:lib:UserList.py", line 27, in __getslice__
return self.__class__(self.data[i:j])
TypeError: too many arguments; expected 1, got 2
A possible solution is to change UserList.py from
def __getslice__(self, i, j):
i = max(i, 0); j = max(j, 0)
return self.__class__(self.data[i:j])
to
def __getslice__(self, i, j):
i = max(i, 0); j = max(j, 0)
return self.data[i:j]
and the other methods accordingly. If for some reasons
this is not possible, consider the code in Python1.5.2
where __getslice__ works (but __*add__ and __mul__
don't)
|