Consider the following two classes:
class Foo0(object):
pass
class Foo1(object):
def __contains__(self, _):
return False
None of them are iterable, which can be seen by trying for i in Foo1(): pass:
Traceback (most recent call last):
File "stuff.py", line 11, in <module>
for i in Foo1(): pass
TypeError: 'Foo1' object is not iterable
And vice versa, it is 3 in Foo1()valid (as it Foo1has __contains__), while 3 in Foo0()not:
Traceback (most recent call last):
File "stuff.py", line 9, in <module>
3 in Foo0()
TypeError: argument of type 'Foo0' is not iterable
. , Foo0 - Foo1 , . , @niemmi @tobias_k , __contains__, __iter__ , . , , __iter__, __contains__.
, ?