Colored diffsΒΆ

One practical use of colors is to make differences in text more visible. ansicolor.colordiff computes a diff of two strings and returns a marked-up version of them that highlights the characters that differ between the two.

from ansicolor import Colors
from ansicolor import colordiff

statement = "All towles must be folded an stowed away neatly inthe closet."
reviewed = "All towels must be folded and stowed neatly in the closet!"

first, second = colordiff(statement, reviewed,
                          color_x=Colors.Cyan, color_y=Colors.Green)

print(first)
print(second)
../_images/colored_diffs_1.png