bpo-37004: Documented asymmetry of string arguments in difflib.Sequen… · python/cpython@7dafbe8

File tree

2 files changed

lines changed

  • Misc/NEWS.d/next/Documentation

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -543,6 +543,16 @@ The :class:`SequenceMatcher` class has this constructor:

543543

to try :meth:`quick_ratio` or :meth:`real_quick_ratio` first to get an

544544

upper bound.

545545
546+

.. note::

547+
548+

Caution: The result of a :meth:`ratio` call may depend on the order of

549+

the arguments. For instance::

550+
551+

>>> SequenceMatcher(None, 'tide', 'diet').ratio()

552+

0.25

553+

>>> SequenceMatcher(None, 'diet', 'tide').ratio()

554+

0.5

555+
546556
547557

.. method:: quick_ratio()

548558
Original file line numberDiff line numberDiff line change

@@ -0,0 +1 @@

1+

In the documentation for difflib, a note was added explicitly warning that the results of SequenceMatcher's ratio method may depend on the order of the input strings.