ID EN
Diff Tools

restore

Python 3.11

Return one of the two sequences that generated a delta.

Syntax

PYTHON
difflib.restore(sequence, which)

Examples

Example 1
PYTHON
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
...              'ore\ntree\nemu\n'.splitlines(keepends=True))
>>> diff = list(diff)  materialize the generated delta into a list
>>> print(''.join(restore(diff, 1)), end="")
one
two
three
>>> print(''.join(restore(diff, 2)), end="")
ore
tree
emu

See Also

Differ.compare() ndiff()