How does __contains__ work? For example I have a class MyClass and an instance of this class called a, when I write if val in a: I'm basically invoking __contains__, from my understanding, if __contains__ is not implemented in the class then __iter__ is invoked, which iterates between the list returned by __getitem__ (which in my example is implemented in the class) and if val is equal to some element of the list then __contains__ returns True. Is it right?
EDIT: __getitem__ in my code only returns the element of the list at a given position so I don't know how would that work together with __iter__