It seems the __getitem__(self, index) function is defined in __init__().
Maybe it’s just a formatting error while pasting the code in the forum, but could you please check it?
__init__, __getitem__ and __len__ should be defined in the class (on the same level).