On 2015-11-12 08:21, Marko Rauhamaa wrote: > And if you really wanted to compare two files that are known to > contain MD5 checksums, the simplest way is: > > with open('f1.md5') as f1, open('f2.md5') as f2: > if f1.read() == f2.read(): > ... > else: > ...
Though that suffers if the files are large. Might try CHUNK_SIZE = 4 * 1024 # read 4k chunks # chunk_offset = 0 with open('f1.md5') as f1, open('f2.md5') as f2: while True: c1 = f1.read(CHUNK_SIZE) c2 = f2.read(CHUNK_SIZE) if c1 or c2: # chunk_offset += 1 if c1 != c2: not_the_same(c1, c2) # not_the_same(chunk_offset * CHUNK_SIZE, c1, c2) break else: # EOF the_same() break which should perform better if the files are huge -tkc -- https://mail.python.org/mailman/listinfo/python-list