]> granicus.if.org Git - python/commitdiff
bpo-37004: Documented asymmetry of string arguments in difflib.SequenceMatcher for...
authorsweeneyde <36520290+sweeneyde@users.noreply.github.com>
Wed, 7 Aug 2019 04:37:08 +0000 (00:37 -0400)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 7 Aug 2019 04:37:08 +0000 (21:37 -0700)
https://bugs.python.org/issue37004

Doc/library/difflib.rst
Misc/NEWS.d/next/Documentation/2019-05-22-04-30-07.bpo-37004.BRgxrt.rst [new file with mode: 0644]

index f044cb2d6e0a865c2f67efceba156845d0fcb4a3..e245ab81cfb9496f6a0b5e941bb4691ecea18470 100644 (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()
 
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 (file)
index 0000000..dfc8b7e
--- /dev/null
@@ -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