Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7dafbe8

Browse files
miss-islingtonsweeneyde
authored andcommitted
bpo-37004: Documented asymmetry of string arguments in difflib.SequenceMatcher for ratio method (GH-13482) (#15158)
https://bugs.python.org/issue37004 (cherry picked from commit e9cbcd0) Co-authored-by: sweeneyde <[email protected]>
1 parent 18343ab commit 7dafbe8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Doc/library/difflib.rst

Lines changed: 10 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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.

0 commit comments

Comments
 (0)