ndiff

Bryan belred1 at yahoo.com
Wed Jul 23 19:55:37 EDT 2003


i tried using ndiff and Differ.compare today from the difflib module.  i
have three questions.

1.  both ndiff and Differ.compare return all the lines including lines that
are the same in both files, not just the diffs.  is the convention to take
the output and then filter out lines that contain a space as the first
character to just get the diffs?  it seems strange to me that the output is
not just the deltas and a lot of wasted filtering (especially if the file is
very large) to get the diff you wanted in the first place.  isn't there a
better way?

2.  i also tried passing IS_LINE_JUNK and IS_CHARACTER_JUNK, but there was
no difference in the output even though i changed some whitespace in the
file.   i then wrote my own junk functions and again, there was no
difference in the output even though i returned 1 to filter out some lines.
can someone show an example of using IS_LINE_JUNK and IS_CHARACTER_JUNK
showing different output than when not using it.

3.  is there a simple method that just returns true or false whether two
files are different or not?  i was hoping that ndiff/compare would return an
empty list if there was no difference,  but that's not the case.  i ended up
using a simple: if file1.read() == file2.read(): but there must be a smarter
faster way.

thanks,

bryan






More information about the Python-list mailing list