The following methods can be defined to further emulate sequence objects. Immutable sequences methods should only define __getslice__(); mutable sequences, should define all three three methods.
self[i:j]
.
The returned object should be of the same type as self. Note
that missing i or j in the slice expression are replaced
by zero or sys.maxint
, respectively. If negative indexes are
used in the slice, the length of the sequence is added to that index.
If the instance does not implement the __len__() method, an
AttributeError is raised.
No guarantee is made that indexes adjusted this way are not still
negative. Indexes which are greater than the length of the sequence
are not modified.
self[i:j]
.
Same notes for i and j as for __getslice__().
self[i:j]
.
Same notes for i and j as for __getslice__().
Notice that these methods are only invoked when a single slice with a single colon is used. For slice operations involving extended slice notation, __getitem__(), __setitem__() or__delitem__() is called.