]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-133986: Document string split algorithm when sep is None and maxsplit is...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 15 May 2025 01:33:38 +0000 (03:33 +0200)
committerGitHub <noreply@github.com>
Thu, 15 May 2025 01:33:38 +0000 (21:33 -0400)
gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (GH-133987)
---------
(cherry picked from commit 3e23047363f384b7254b7af51afe4e353be94167)

Co-authored-by: Joey Smith <joeysmith@gmail.com>
Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Doc/library/stdtypes.rst

index 0936be0caaf9038544ba70d3dd5f09c72a131655..ccaa0efaada7c70deac650832c4d7fd24ada4faa 100644 (file)
@@ -2133,6 +2133,18 @@ expression support in the :mod:`re` module).
       >>> '   1   2   3   '.split()
       ['1', '2', '3']
 
+   If *sep* is not specified or is ``None`` and  *maxsplit* is ``0``, only
+   leading runs of consecutive whitespace are considered.
+
+   For example::
+
+      >>> "".split(None, 0)
+      []
+      >>> "   ".split(None, 0)
+      []
+      >>> "   foo   ".split(maxsplit=0)
+      ['foo   ']
+
 
 .. index::
    single: universal newlines; str.splitlines method