How do I compare files?

GHZ geraint.williams at
Wed Jul 23 02:02:03 CEST 2008

On Jul 23, 1:27 am, Clay Hobbs <c... at> wrote:
> I am making a program that (with urllib) that downloads two jpeg files
> and, if they are different, displays the new one.  I need to find a way
> to compare two files in Python.  How is this done?
> -- Ratfink

import hashlib

file = open(path)
m = hashlib.md5()
digest = m.hexdigest()

and compare the digest on both files

More information about the Python-list mailing list