How does Python (2.6.4, specifically) determine list membership in general? I\'ve run some tests to see what it does:
def main():
obj = fancy_obj(arg=\'
From (An Unofficial) Python Reference Wiki:
For the list and tuple types, x in y
is true if and only if there exists an index i such that x == y[i]
is true.
So in your example, if the fancy_obj
class stored the value of arg
in an instance variable and were to implement an __eq__
method that returned True if the two fancy_objs
being compared had the same value for arg
then (1, fancy_obj(arg='C:\\'),) in haystack
would be True.
The relevant page of the Standard Library reference is: Built-in Types, specifically 5.6 Sequence Types