]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings (#113355)
authorErlend E. Aasland <erlend@python.org>
Thu, 21 Dec 2023 14:22:39 +0000 (15:22 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Dec 2023 14:22:39 +0000 (15:22 +0100)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.

Objects/clinic/unicodeobject.c.h
Objects/unicodeobject.c

index 7711434f17c2bc5e1dad2499ee7e767a72a915f3..3e5167d9242fe4cb743201d075e35e9b0bfa1af1 100644 (file)
@@ -954,9 +954,11 @@ PyDoc_STRVAR(unicode_split__doc__,
 "    character (including \\n \\r \\t \\f and spaces) and will discard\n"
 "    empty strings from the result.\n"
 "  maxsplit\n"
-"    Maximum number of splits (starting from the left).\n"
+"    Maximum number of splits.\n"
 "    -1 (the default value) means no limit.\n"
 "\n"
+"Splitting starts at the front of the string and works to the end.\n"
+"\n"
 "Note, str.split() is mainly useful for data that has been intentionally\n"
 "delimited.  With natural text that includes punctuation, consider using\n"
 "the regular expression module.");
@@ -1078,7 +1080,7 @@ PyDoc_STRVAR(unicode_rsplit__doc__,
 "    character (including \\n \\r \\t \\f and spaces) and will discard\n"
 "    empty strings from the result.\n"
 "  maxsplit\n"
-"    Maximum number of splits (starting from the left).\n"
+"    Maximum number of splits.\n"
 "    -1 (the default value) means no limit.\n"
 "\n"
 "Splitting starts at the end of the string and works to the front.");
@@ -1505,4 +1507,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=873d8b3d09af3095 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1aab29bab5201c78 input=a9049054013a1b77]*/
index 836e14fd5d5dea972abd13f58cb95a930eedfd83..ad87206b2a82001bac6e3ad54f3b0564844e8eb7 100644 (file)
@@ -12504,11 +12504,13 @@ str.split as unicode_split
         character (including \n \r \t \f and spaces) and will discard
         empty strings from the result.
     maxsplit: Py_ssize_t = -1
-        Maximum number of splits (starting from the left).
+        Maximum number of splits.
         -1 (the default value) means no limit.
 
 Return a list of the substrings in the string, using sep as the separator string.
 
+Splitting starts at the front of the string and works to the end.
+
 Note, str.split() is mainly useful for data that has been intentionally
 delimited.  With natural text that includes punctuation, consider using
 the regular expression module.
@@ -12517,7 +12519,7 @@ the regular expression module.
 
 static PyObject *
 unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=3a65b1db356948dc input=07b9040d98c5fe8d]*/
+/*[clinic end generated code: output=3a65b1db356948dc input=a29bcc0c7a5af0eb]*/
 {
     if (sep == Py_None)
         return split(self, NULL, maxsplit);