Specifics of List Membership
- by phasetwenty
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='C:\\')
needle = (50, obj)
haystack = [(50, fancy_obj(arg='C:\\')), (1, obj,), needle]
print (1, fancy_obj(arg='C:\\'),) in haystack
print needle in haystack
if __name__ == '__main__':
main()
Which yields:
False
True
This tells me that Python is probably checking the object references, which makes sense. Is there something more definitive I can look at?