>>> class Thing(object): ... def __index__(self): ... return 1 ... >>> thing = Thing() >>> list_ = [\'abc\', \'def\', \'ghi\'
Dict and List does not implement __getitem__ the same way. Dict objects uses a comparison (__eq__) on __hash__ of objects as key to use in __getitem__.
__getitem__
__eq__
__hash__
To make Thing usable for dict you have to implement both hash and eq.
Thing