class A: def __init__(self): self.a = [1, 2, 3, 4] def __getitem__(self, ind): return self.a[ind] a = A() for el in a: print(el)