views:

32

answers:

1

I'm using Python 2.6.2. The docs for the filecmp module say:

The filecmp module defines functions to compare files and directories, with various optional time/correctness trade-offs.

and, of the filecmp.cmp function:

filecmp.cmp(f1, f2[, shallow])

Compare the files named f1 and f2, returning True if they seem equal, False otherwise.

Unless shallow is given and is false, files with identical os.stat() signatures are taken to be equal.

What they don't do is specify just what is the correctness level one obtains with shallow=False. So, what does shallow=False do? How correct is it?

+1  A: 

[I've answered myself as I first searched SO, then wrote up my question, and, before posting, thought "Use the source, Luke". Since I didn't find it here, I post Q&A. I'm new; apologies if this is bad form.]

Consulting the source filecmp.py' reveals that isshallow=False`, filecmp.cmp does an exact contents comparison by reading and comparing chunks of each file. It returns True only if the two files have exactly the same contents.

vanden