Comparing file objects: what is compared?
mwh21 at cam.ac.uk
Fri Feb 11 12:22:17 EST 2000
Gerrit Holl <gerrit.holl at pobox.com> writes:
> >>> fp1=open('/tmp/file_one', 'w')
> >>> fp2=open('/tmp/file_two', 'w')
> >>> cmp(fp1, fp2)
> >>> cmp(fp2, fp1)
> What is compared? The date of creation? The filename? The contents?
> I've searched the FAQ, the documentation, the sig archives and the
> newsgroup, but I'm not able to find the answer. What is compared when
> comparing file objects?
File objects have no specialized "cmp" method, so get the default
cmp(fp1,fp2) == cmp(id(fp1),id(fp2))
More information about the Python-list