How do I compare files?

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


On Jul 23, 1:27 am, Clay Hobbs <c... at lakeserv.net> 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()
m.update(file.read())
digest = m.hexdigest()
file.close()


and compare the digest on both files



More information about the Python-list mailing list