]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (#133987)
authorJoey Smith <joeysmith@gmail.com>
Wed, 14 May 2025 10:17:26 +0000 (04:17 -0600)
committerGitHub <noreply@github.com>
Wed, 14 May 2025 10:17:26 +0000 (06:17 -0400)
* Document string split algorithm when sep is None and maxsplit is 0

* Update Doc/library/stdtypes.rst

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
---------

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

index 1d9a655c7664ea2b0c259bdc3ecf2dbdfccc5f1c..3486a18b5cb1f0fe225c7cecf36c2f4a3ef5ccdc 100644 (file)
@@ -2269,6 +2269,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