On this page
difflib.Match
Prev: difflib.HtmlDiff | Up: difflib | Next: difflib.ndiff
Rel: difflib.context_diff, difflib.diff_bytes, difflib.Differ, difflib.get_close_matches
Ref: docs.python.org โ difflib.Match
Tags: #public #python3 #stdlib #difflib
Import
import difflib
from difflib import Match
Signature & Overview
difflib.Match(a, b, size)
Match(a, b, size)
Methods & Attributes
Match.count(self, value, /)โ Return number of occurrences of value.Match.index(self, value, start=0, stop=9223372036854775807, /)โ Return first index of value.
Usage
import difflib
m = difflib.SequenceMatcher(None, "abcdef", "xbcdey").find_longest_match(0, 6, 0, 6)
assert isinstance(m, difflib.Match) and (m.a, m.b, m.size) == (1, 1, 4)
Gotchas
- Named tuple
(a, b, size):seq1[m.a : m.a + m.size] == seq2[m.b : m.b + m.size].
REPL Inspect
from difflib import Match
help(Match)
Linked from
Related notes
- tuts/python3/stdlib_module/difflib/HtmlDiff Linked here; links to this page; shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/ndiff Linked here; links to this page; shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/difflib/context_diff Linked here; shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/diff_bytes Linked here; shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/Differ Linked here; shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/get_close_matches Linked here; shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/restore shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/SequenceMatcher shared tags: #difflib, #stdlib
- tuts/python3/stdlib_module/difflib/unified_diff shared tags: #difflib, #stdlib