class testClass(): def __init__(self): self.dataList = [1,2,3,4,5] def __getitem__(self, key): return self.dataList[key] a = testClass() a[1] # 2 a[2] # 3