If a class defines it, this special method is called
whenever a value is retrieved from a sequence or
mapping (dictionary-like object) using the syntax
“”,
where v[i] is
the sequence or mapping and v is a position in a sequence,
or a key in a mapping.
i
Here is the calling sequence:
def __getitem__(self, i):
...
The method either returns the corresponding item or
raises an appropriate exception: IndexError for sequences or KeyError for mappings.