How to use cmp() function to compare 2 files?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Tue Feb 27 01:07:23 EST 2007
In <1172553141.665287.65280 at 8g2000cwh.googlegroups.com>, yinglcs at gmail.com
wrote:
> File "./scripts/regressionTest.py", line 30, in getSnapShot
> if (difflib.context_diff(f1.readlines(), f2.readlines()).len() ==
> 0):
> # no difference
> else:
> # files are different
> AttributeError: 'generator' object has no attribute 'len'
>
> Can you please help?
The function returns a generator/iterator over the differences which has
no `len()` method. If you just want to know if two files are equal or not
use `filecmp.cmp()`. Read the docs about the `shallow` argument of that
function.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list