MCPcopy Index your code
hub / github.com/python/cpython / __init__

Method __init__

Lib/difflib.py:121–183  ·  view source on GitHub ↗

Construct a SequenceMatcher. Optional arg isjunk is None (the default), or a one-argument function that takes a sequence element and returns true iff the element is junk. None is equivalent to passing "lambda x: 0", i.e. no elements are considered to be junk. For e

(self, isjunk=None, a='', b='', autojunk=True)

Source from the content-addressed store, hash-verified

119 """
120
121 def __init__(self, isjunk=None, a='', b='', autojunk=True):
122 """Construct a SequenceMatcher.
123
124 Optional arg isjunk is None (the default), or a one-argument
125 function that takes a sequence element and returns true iff the
126 element is junk. None is equivalent to passing "lambda x: 0", i.e.
127 no elements are considered to be junk. For example, pass
128 lambda x: x in " \\t"
129 if you're comparing lines as sequences of characters, and don't
130 want to synch up on blanks or hard tabs.
131
132 Optional arg a is the first of two sequences to be compared. By
133 default, an empty string. The elements of a must be hashable. See
134 also .set_seqs() and .set_seq1().
135
136 Optional arg b is the second of two sequences to be compared. By
137 default, an empty string. The elements of b must be hashable. See
138 also .set_seqs() and .set_seq2().
139
140 Optional arg autojunk should be set to False to disable the
141 "automatic junk heuristic" that treats popular elements as junk
142 (see module documentation for more information).
143 """
144
145 # Members:
146 # a
147 # first sequence
148 # b
149 # second sequence; differences are computed as "what do
150 # we need to do to 'a' to change it into 'b'?"
151 # b2j
152 # for x in b, b2j[x] is a list of the indices (into b)
153 # at which x appears; junk and popular elements do not appear
154 # fullbcount
155 # for x in b, fullbcount[x] == the number of times x
156 # appears in b; only materialized if really needed (used
157 # only for computing quick_ratio())
158 # matching_blocks
159 # a list of (i, j, k) triples, where a[i:i+k] == b[j:j+k];
160 # ascending & non-overlapping in i and in j; terminated by
161 # a dummy (len(a), len(b), 0) sentinel
162 # opcodes
163 # a list of (tag, i1, i2, j1, j2) tuples, where tag is
164 # one of
165 # 'replace' a[i1:i2] should be replaced by b[j1:j2]
166 # 'delete' a[i1:i2] should be deleted
167 # 'insert' b[j1:j2] should be inserted
168 # 'equal' a[i1:i2] == b[j1:j2]
169 # isjunk
170 # a user-supplied function taking a sequence element and
171 # returning true iff the element is "junk" -- this has
172 # subtle but helpful effects on the algorithm, which I'll
173 # get around to writing up someday <0.9 wink>.
174 # DON'T USE! Only __chain_b uses this. Use "in self.bjunk".
175 # bjunk
176 # the items in b for which isjunk is True.
177 # bpopular
178 # nonjunk items in b treated as junk by the heuristic (if used).

Callers

nothing calls this directly

Calls 1

set_seqsMethod · 0.95

Tested by

no test coverage detected