Method: difflib.ndiff
Calls: 20, Exceptions: 0, Paths: 1Back
Path 1: 20 calls (1.0)
['', ' 1. Beautiful is beTTer than ugly.', ' 2. Explicit is better than implicit.', ' 3. Simple is better than complex.', ' 4. Complex is bett...
['', ' 1. Beautiful is better than ugly.', ' 3. Simple is better than complex.', ' 4. Complicated is better than complex.', ' 5. Flat is bet...
None (20)
IS_CHARACTER_JUNK def (20)
Differ.compare def (20)
1def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK):
2 r"""
3 Compare `a` and `b` (lists of strings); return a `Differ`-style delta.
4
5 Optional keyword parameters `linejunk` and `charjunk` are for filter
6 functions, or can be None:
7
8 - linejunk: A function that should accept a single string argument and
9 return true iff the string is junk. The default is None, and is
10 recommended; the underlying SequenceMatcher class has an adaptive
11 notion of "noise" lines.
12
13 - charjunk: A function that accepts a character (string of length
14 1), and returns true iff the character is junk. The default is
15 the module-level function IS_CHARACTER_JUNK, which filters out
16 whitespace characters (a blank or tab; note: it's a bad idea to
17 include newline in this!).
18
19 Tools/scripts/ndiff.py is a command-line front-end to this function.
20
21 Example:
22
23 >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
24 ... 'ore\ntree\nemu\n'.splitlines(keepends=True))
25 >>> print(''.join(diff), end="")
26 - one
27 ? ^
28 + ore
29 ? ^
30 - two
31 - three
32 ? -
33 + tree
34 + emu
35 """
36 return Differ(linejunk, charjunk).compare(a, b)