Indexing and slicing

__getitem__(self, i): used for subscripting:
b = a[i]
__setitem__(self, i, v): used for subscripting: a[i] = v
__delitem__(self, i): used for deleting: del a[i]
These three functions are also used for slices:
a[p:q:r] implies that i is a slice object with attributes start (p), stop (q) and step (r)
b = a[:-1]
# implies
b = a.__getitem__(i)
isinstance(i, slice) is True
i.start is None
i.stop  is -1
i.step  is None

previousnexttable of contents