difflib.SequenceMatcher()
difflib.SequenceMatcher() is a Python function in the Difflib Module category. Flexible sequence comparison object. Finds the longest matching subsequences. The syntax is difflib.SequenceMatcher(isjunk=None, a="", b="", autojunk=True). Returns: SequenceMatcher object. A typical example: import difflib
m = difflib.SequenceMatcher(None, "kitten", "sitting")
m.ratio() # 0.615 (similarity ratio). A close sibling is difflib.get_close_matches(), which returns the best `n` matches for a word from a list of possibilities. A close sibling is difflib.unified_diff(), which compares two sequences and produces a unified diff output (like diff -u). A close sibling is difflib.context_diff(), which compares sequences and produces a context diff (like diff -c). A close sibling is difflib.ndiff(), which compares sequences and produces a human-readable delta (like diff). More about this category: Sequence comparison — SequenceMatcher, get_close_matches, unified_diff. For a broader walkthrough, read the Difflib Module guide. Related Difflib Module entries: difflib.get_close_matches(), difflib.unified_diff(), difflib.context_diff(), difflib.ndiff(), difflib.HtmlDiff().