PyDocs

Text Processing Services

difflib

Module difflib -- helpers for computing deltas between objects.

Function get_close_matches(word, possibilities, n=3, cutoff=0.6):
    Use SequenceMatcher to return list of the best "good enough" matches.

Function context_diff(a, b):
    For two lists of strings, return a delta in context diff format.

Function ndiff(a, b):
    Return a delta: the difference between `a` and `b` (lists of strings).

Function restore(delta, which):
    Return one of the two sequences that generated an ndiff delta.

Function unified_diff(a, b):
    For two lists of strings, return a delta in unified diff format.

Class SequenceMatcher:
    A flexible class for comparing pairs of sequences of any type.

Class Differ:
    For producing human-readable deltas from sequences of lines of text.

Class HtmlDiff:
    For producing HTML side by side comparison with change highlights.
Symbols in difflib

c

context_diff
Compare two sequences of lines; generate the delta as a context diff.

d

diff_bytes
Compare `a` and `b`, two sequences of lines represented as bytes rather than str.
Differ
Differ is a class for comparing sequences of lines of text, and producing human-readable differences or deltas.

g

get_close_matches
Use SequenceMatcher to return list of the best "good enough" matches.

h

HtmlDiff
For producing HTML side by side comparison with change highlights.

i

IS_CHARACTER_JUNK
Return True for ignorable character: iff `ch` is a space or tab.
IS_LINE_JUNK
Return True for ignorable line: if `line` is blank or contains a single '#'.

n

ndiff
Compare `a` and `b` (lists of strings); return a `Differ`-style delta.

r

restore
Generate one of the two sequences that generated a delta.

s

SequenceMatcher
SequenceMatcher is a flexible class for comparing pairs of sequences of any type, so long as the sequence elements are hashable.

u

unified_diff
Compare two sequences of lines; generate the delta as a unified diff.