index out of range with slice object

Uwe Mayer merkosh at
Wed Mar 10 20:53:41 CET 2004


a class of mine should support the list interface and implements the __len__
and __getitem__ methods.

Now when I ask for an unbounded slice:

>>> len( myObj[:] )

my __getitem__(self, y) method gets called with 

    y = slice(0, 2147483647, None)

Now step size is ok, but where does that incredibly large stop index come
from? Also I expected the start index rather to be None than zero.
The __len__(self) method returns the correct length, which is 728.

Has anybody encountered something like that bevore? Is that natural or am I
doing something wrong?

Thanks in advance

More information about the Python-list mailing list