binary file compare...

SpreadTooThin bjobrien62 at gmail.com
Mon Apr 13 16:17:02 EDT 2009


On Apr 13, 2:03 pm, Grant Edwards <invalid at invalid> wrote:
> On 2009-04-13, SpreadTooThin <bjobrie... at gmail.com> wrote:
>
> > I want to compare two binary files and see if they are the same.
> > I see the filecmp.cmp function but I don't get a warm fuzzy feeling
> > that it is doing a byte by byte comparison of two files to see if they
> > are they same.
>
> Perhaps I'm being dim, but how else are you going to decide if
> two files are the same unless you compare the bytes in the
> files?
>
> You could hash them and compare the hashes, but that's a lot
> more work than just comparing the two byte streams.
>
> > What should I be using if not filecmp.cmp?
>
> I don't understand what you've got against comparing the files
> when you stated that what you wanted to do was compare the files.
>

I think its just the way the documentation was worded
http://www.python.org/doc/2.5.2/lib/module-filecmp.html

Unless shallow is given and is false, files with identical os.stat()
signatures are taken to be equal.
Files that were compared using this function will not be compared
again unless their os.stat() signature changes.

So to do a comparison:
filecmp.cmp(filea, fileb, False)
?




> --
> Grant Edwards                   grante             Yow! Look DEEP into the
>                                   at               OPENINGS!!  Do you see any
>                                visi.com            ELVES or EDSELS ... or a
>                                                    HIGHBALL?? ...




More information about the Python-list mailing list