Changeset 391 for python/trunk/Doc/library/difflib.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/difflib.rst
r2 r391 38 38 time is linear. 39 39 40 **Automatic junk heuristic:** :class:`SequenceMatcher` supports a heuristic that 41 automatically treats certain sequence items as junk. The heuristic counts how many 42 times each individual item appears in the sequence. If an item's duplicates (after 43 the first one) account for more than 1% of the sequence and the sequence is at least 44 200 items long, this item is marked as "popular" and is treated as junk for 45 the purpose of sequence matching. This heuristic can be turned off by setting 46 the ``autojunk`` argument to ``False`` when creating the :class:`SequenceMatcher`. 47 48 .. versionadded:: 2.7.1 49 The *autojunk* parameter. 40 50 41 51 .. class:: Differ … … 75 85 76 86 77 .. function:: __init__( [tabsize][, wrapcolumn][, linejunk][, charjunk])87 .. function:: __init__(tabsize=8, wrapcolumn=None, linejunk=None, charjunk=IS_CHARACTER_JUNK) 78 88 79 89 Initializes instance of :class:`HtmlDiff`. … … 147 157 The context diff format normally has a header for filenames and modification 148 158 times. Any or all of these may be specified using strings for *fromfile*, 149 *tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally150 expressed in the format returned by :func:`time.ctime`.If not specified, the159 *tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally 160 expressed in the ISO 8601 format. If not specified, the 151 161 strings default to blanks. 152 162 … … 282 292 The context diff format normally has a header for filenames and modification 283 293 times. Any or all of these may be specified using strings for *fromfile*, 284 *tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally285 expressed in the format returned by :func:`time.ctime`.If not specified, the294 *tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally 295 expressed in the ISO 8601 format. If not specified, the 286 296 strings default to blanks. 287 297 … … 335 345 336 346 337 .. class:: SequenceMatcher( [isjunk[, a[, b]]])347 .. class:: SequenceMatcher(isjunk=None, a='', b='', autojunk=True) 338 348 339 349 Optional argument *isjunk* must be ``None`` (the default) or a one-argument … … 351 361 empty strings. The elements of both sequences must be :term:`hashable`. 352 362 363 The optional argument *autojunk* can be used to disable the automatic junk 364 heuristic. 365 366 .. versionadded:: 2.7.1 367 The *autojunk* parameter. 368 353 369 :class:`SequenceMatcher` objects have the following methods: 354 355 370 356 371 .. method:: set_seqs(a, b) … … 513 528 Return an upper bound on :meth:`ratio` relatively quickly. 514 529 515 This isn't defined beyond that it is an upper bound on :meth:`ratio`, and516 is faster to compute.517 518 530 519 531 .. method:: real_quick_ratio() … … 521 533 Return an upper bound on :meth:`ratio` very quickly. 522 534 523 This isn't defined beyond that it is an upper bound on :meth:`ratio`, and524 is faster to compute than either :meth:`ratio` or :meth:`quick_ratio`.525 535 526 536 The three methods that return the ratio of matching to total characters can give … … 623 633 Compare two sequences of lines, and generate the delta (a sequence of lines). 624 634 625 Each sequence must contain individual single-line strings ending with newlines. 626 Such sequences can be obtained from the :meth:`readlines` method of file-like 627 objects. The delta generated also consists of newline-terminated strings, ready 628 to be printed as-is via the :meth:`writelines` method of a file-like object. 635 Each sequence must contain individual single-line strings ending with 636 newlines. Such sequences can be obtained from the 637 :meth:`~file.readlines` method of file-like objects. The delta 638 generated also consists of newline-terminated strings, ready to be 639 printed as-is via the :meth:`~file.writelines` method of a 640 file-like object. 629 641 630 642 … … 636 648 This example compares two texts. First we set up the texts, sequences of 637 649 individual single-line strings ending with newlines (such sequences can also be 638 obtained from the :meth:` readlines` method of file-like objects):650 obtained from the :meth:`~file.readlines` method of file-like objects): 639 651 640 652 >>> text1 = ''' 1. Beautiful is better than ugly.
Note:
See TracChangeset
for help on using the changeset viewer.