Konstantin Tretyakov added the comment:
Aha, I see. I knew I'd get bitten by not explicitly subclassing (object) one
day.
In any case, adding a reference to this issue into the docs of __getitem__ and
__setitem__ would probably save someone some hours of utter confusion in the
f
Konstantin Tretyakov added the comment:
Do note that things are not as simple as "slices with negative indices are
treated differently from scalar negative indicies".
Namely, behaviour differs whether you use [] or .__getitem__, and whether you
use [a:b] or [slice(a,b)]. This doe
New submission from Konstantin Tretyakov:
Consider the following example:
class A:
def __getitem__(self, index):
return True
If you invoke A()[-1], everything is fine. However, if you invoke A()[-1:2],
you get an "AttributeError: A instance has no attribute '__len__