bpo-37004: Documented asymmetry of string arguments in difflib.SequenceMatcher for ratio method (GH-13482) (#15157)

https://bugs.python.org/issue37004
(cherry picked from commit e9cbcd0018)

Co-authored-by: sweeneyde <36520290+sweeneyde@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2019-08-07 08:39:14 -07:00 committed by Terry Jan Reedy
parent e780d2f1f5
commit 1a3a40c1cb
2 changed files with 11 additions and 0 deletions

View File

@ -543,6 +543,16 @@ The :class:`SequenceMatcher` class has this constructor:
to try :meth:`quick_ratio` or :meth:`real_quick_ratio` first to get an
upper bound.
.. note::
Caution: The result of a :meth:`ratio` call may depend on the order of
the arguments. For instance::
>>> SequenceMatcher(None, 'tide', 'diet').ratio()
0.25
>>> SequenceMatcher(None, 'diet', 'tide').ratio()
0.5
.. method:: quick_ratio()

View File

@ -0,0 +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.