Note that Differ-generated deltas make no claim to be
minimal diffs. To the contrary, minimal diffs are often
counter-intuitive, because they synch up anywhere possible, sometimes
accidental matches 100 pages apart. Restricting synch points to
contiguous matches preserves some notion of locality, at the
occasional cost of producing a longer diff.
The Differ class has this constructor:
classDiffer(
[linejunk[, charjunk]])
Optional keyword parameters linejunk and charjunk are
for filter functions (or None):
linejunk: A function that accepts a single string
argument, and returns true if the string is junk. The default is
None, meaning that no line is considered junk.
charjunk: A function that accepts a single character argument
(a string of length 1), and returns true if the character is junk.
The default is None, meaning that no character is
considered junk.
Differ objects are used (deltas generated) via a single
method:
compare(
a, b)
Compare two sequences of lines, and generate the delta (a sequence
of lines).
Each sequence must contain individual single-line strings ending
with newlines. Such sequences can be obtained from the
readlines() method of file-like objects. The delta generated
also consists of newline-terminated strings, ready to be printed as-is
via the writelines() method of a file-like object.