PyDocs

Nav

Text Processing Services

Differ.compare

difflib

method of Differ (source)
  • Differ.compare(a, b)
Compare two sequences of lines; generate the resulting delta.

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.

Example:

>>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(True),
...                                'ore\ntree\nemu\n'.splitlines(True))),
...       end="")
- one
?  ^
+ ore
?  ^
- two
- three
?  -
+ tree
+ emu
1 Example
>>> result = list(d.compare(text1, text2))
from the Python docs
See Also
No see-alsos for difflib/Differ.compare
0 Notes
No notes for Differ.compare