So this question got me thinking. I did some testing with multiple file handles for the same file, and found some odd results that I was hoping someone could explain.
>>> f1 = open("test.txt",'w')
>>> f1.close()
>>> f1, f2 = open("test.txt", 'w'), open("test.txt", 'w')
>>> f1 == f2
False
>>> f1, f2 = open("test.txt", 'r'), open("test.txt", 'r')
>>> f1 == f2
False
Why do these tests not return True
? Surely assigning a handle to the same file should have the same value.
What's the underlying mechanism for these comparisons to return False
and what is the rationale for creating this behavior?