• Home
  • Raw
  • Download

Lines Matching +full:supports +full:- +full:hyperlinks

1 :mod:`difflib` --- Helpers for computing deltas
18 --------------
41 **Timing:** The basic Ratcliff-Obershelp algorithm is cubic time in the worst
43 quadratic time for the worst case and has expected-case behavior dependent in a
47 **Automatic junk heuristic:** :class:`SequenceMatcher` supports a heuristic that
62 human-readable differences or deltas. Differ uses :class:`SequenceMatcher`
64 within similar (near-matching) lines.
66 Each line of a :class:`Differ` delta begins with a two-letter code:
68 +----------+-------------------------------------------+
71 | ``'- '`` | line unique to sequence 1 |
72 +----------+-------------------------------------------+
74 +----------+-------------------------------------------+
76 +----------+-------------------------------------------+
78 +----------+-------------------------------------------+
89 with inter-line and intra-line change highlights. The table can be generated in
112 numlines=5, *, charset='utf-8')
116 inter-line and intra-line changes highlighted.
127 "next" hyperlinks (setting to zero would cause the "next" hyperlinks to place
136 *charset* keyword-only argument was added. The default charset of
137 HTML document changed from ``'ISO-8859-1'`` to ``'utf-8'``.
142 is a complete HTML table showing line by line differences with inter-line and
143 intra-line changes highlighted.
148 :file:`Tools/scripts/diff.py` is a command-line front-end to this class and
161 By default, the diff control lines (those with ``***`` or ``---``) are created
180 --- after.py
187 --- 1,4 ----
193 See :ref:`difflib-interface` for a more detailed example.
224 Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style
232 is also a module-level function :func:`IS_LINE_JUNK`, which filters out lines
234 -- however the underlying :class:`SequenceMatcher` class does a dynamic
239 returns if the character is junk, or false if not. The default is module-level
243 :file:`Tools/scripts/ndiff.py` is a command-line front-end to this function.
248 - one
252 - two
253 - three
254 ? -
292 By default, the diff control lines (those with ``---``, ``+++``, or ``@@``) are
311 --- before.py
313 @@ -1,4 +1,4 @@
314 -bacon
315 -eggs
316 -ham
322 See :ref:`difflib-interface` for a more detailed example.
356 …g: The Gestalt Approach <https://www.drdobbs.com/database/pattern-matching-the-gestalt-approach/18…
361 .. _sequence-matcher:
364 -----------------------
371 Optional argument *isjunk* must be ``None`` (the default) or a one-argument
393 non-junk elements considered popular by the heuristic (if it is not
468 Return list of triples describing non-overlapping matching subsequences.
477 triples always describe non-adjacent equal blocks.
490 Return list of 5-tuples describing how to turn *a* into *b*. Each tuple is
497 +---------------+---------------------------------------------+
502 +---------------+---------------------------------------------+
505 +---------------+---------------------------------------------+
509 +---------------+---------------------------------------------+
510 | ``'equal'`` | ``a[i1:i2] == b[j1:j2]`` (the sub-sequences |
512 +---------------+---------------------------------------------+
520 ... print('{:7} a[{}:{}] --> b[{}:{}] {!r:>8} --> {!r}'.format(
522 delete a[0:1] --> b[0:0] 'q' --> ''
523 equal a[1:3] --> b[0:2] 'ab' --> 'ab'
524 replace a[3:4] --> b[2:3] 'x' --> 'y'
525 equal a[4:6] --> b[3:5] 'cd' --> 'cd'
526 insert a[6:6] --> b[5:6] '' --> 'f'
589 .. _sequencematcher-examples:
592 ------------------------
640 .. _differ-objects:
643 --------------
645 Note that :class:`Differ`\ -generated deltas make no claim to be **minimal**
646 diffs. To the contrary, minimal diffs are often counter-intuitive, because they
668 These junk-filtering functions speed up matching to find
681 Each sequence must contain individual single-line strings ending with
683 :meth:`~io.IOBase.readlines` method of file-like objects. The delta
684 generated also consists of newline-terminated strings, ready to be
685 printed as-is via the :meth:`~io.IOBase.writelines` method of a
686 file-like object.
689 .. _differ-examples:
692 --------------
695 individual single-line strings ending with newlines (such sequences can also be
696 obtained from the :meth:`~io.BaseIO.readlines` method of file-like objects):
705 >>> text1[0][-1]
725 ``result`` is a list of strings, so let's pretty-print it:
730 '- 2. Explicit is better than implicit.\n',
731 '- 3. Simple is better than complex.\n',
734 '- 4. Complex is better than complicated.\n',
735 '? ^ ---- ^\n',
740 As a single multi-line string it looks like this:
745 - 2. Explicit is better than implicit.
746 - 3. Simple is better than complex.
749 - 4. Complex is better than complicated.
750 ? ^ ---- ^
756 .. _difflib-interface:
758 A command-line interface to difflib
759 -----------------------------------
761 This example shows how to use difflib to create a ``diff``-like utility.