__getitem__, __getslice__ question for python 2.2
Edward C. Jones
edcjones at erols.com
Sat May 11 12:05:01 EDT 2002
In Python 2.2 the following code outputs [1, 2] but never gets to line 8:
class test(list):
def __init__(self, data=[]):
list.__init__(self, data)
def __getitem__(self, key):
print 'L8', key
return list.__getitem__(self, key)
# def __getslice__(self, lo, hi):
# print 'L12', lo, hi
# return list.__getslice__(self, lo, hi)
x = test([0,1,2,3,4])
print x[1:3]
If __getslice__ is uncommented, [1, 2] is output and line 12 is executed.
What is going on here? What is the status of the deprecation of
__getslice__? How does this all relate to the new style classes?
Thanks,
Ed Jones
More information about the Python-list
mailing list