The cmp Module

(Obsolete, Only in 1.5.2) The cmp module contains a function to compare two files, as Example 14-19 demonstrates.

Example 14-19. Using the cmp Module

File: cmp-example-1.py

import cmp

if cmp.cmp("samples/sample.au", "samples/sample.wav"):
    print "files are identical"
else:
    print "files differ!"

files differ!

In Python 2.0 and later, this module has been replaced by the filecmp module.

Get Python Standard Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.