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

Terry Jan Reedy webhook-mailer at python.org
Wed Aug 7 11:39:37 EDT 2019


https://github.com/python/cpython/commit/1a3a40c1cb582e436d568009fae2b06c0b1978ed
commit: 1a3a40c1cb582e436d568009fae2b06c0b1978ed
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Terry Jan Reedy <tjreedy at udel.edu>
date: 2019-08-07T11:39:14-04:00
summary:

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 e9cbcd0018abd2a5f2348c45d5c9c4265c4f42dc)

Co-authored-by: sweeneyde <36520290+sweeneyde at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Documentation/2019-05-22-04-30-07.bpo-37004.BRgxrt.rst
M Doc/library/difflib.rst

diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
index f044cb2d6e0a..e245ab81cfb9 100644
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -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()
 
diff --git a/Misc/NEWS.d/next/Documentation/2019-05-22-04-30-07.bpo-37004.BRgxrt.rst b/Misc/NEWS.d/next/Documentation/2019-05-22-04-30-07.bpo-37004.BRgxrt.rst
new file mode 100644
index 000000000000..dfc8b7ed74ca
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2019-05-22-04-30-07.bpo-37004.BRgxrt.rst
@@ -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.
\ No newline at end of file



More information about the Python-checkins mailing list