When we implement our own obj in python which support for i in obj statement, what magic method we need to create?
Is there a link to the official document that I can check?
During my reading of some other's source code, I found there's a __getitem__
method, it has a signatue of __getitem__(slef, index)
, then when we instantiate an object of this class, and call
for i in obj:
print(i)
what method would python try to find and pass what argument?