ListDifferently
¶
- class differently.ListDifferently(a: Optional[List[str]], b: Optional[List[str]], color: bool = True)¶
Visualises the differences between two lists of strings.
Use the string representation or
render()
to render.- Parameters
a – First list
b – Second list
color – Include or exclude colour formatting (default is True)
Example
from differently import ListDifferently diff = ListDifferently( [ "It was the best of times,", "It was the burst of times.", ], [ "It was the best of times,", "It was the worst of times.", "It was the age of wisdom...", ], color=False, ) print(diff)
It was the best of times, = It was the best of times, It was the burst of times. ~ It was the worst of times. > It was the age of wisdom...
- property differences: List[differently.string_differently.StringDifferently]¶
Gets the
StringDifferently
that make up the differences between the lists.
- render(writer: IO[str]) None ¶
Renders the visualisation to writer.
- Parameters
writer – Writer
Example
from io import StringIO from differently import ListDifferently diff = ListDifferently( ["first", "seccond"], ["first", "second", "third"], color=False, ) writer = StringIO() diff.render(writer) print(writer.getvalue())
first = first seccond ~ second > third