Skip to content

Commit bd3add0

Browse files
miss-islingtontmlnedbatdonBarbos
authored
[3.13] gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (GH-133987) (#133992)
gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (GH-133987) --------- (cherry picked from commit 3e23047) Co-authored-by: Joey Smith <joeysmith@gmail.com> Co-authored-by: Ned Batchelder <ned@nedbatchelder.com> Co-authored-by: Semyon Moroz <donbarbos@proton.me>
1 parent f474264 commit bd3add0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,6 +2133,18 @@ expression support in the :mod:`re` module).
21332133
>>> ' 1 2 3 '.split()
21342134
['1', '2', '3']
21352135

2136+
If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only
2137+
leading runs of consecutive whitespace are considered.
2138+
2139+
For example::
2140+
2141+
>>> "".split(None, 0)
2142+
[]
2143+
>>> " ".split(None, 0)
2144+
[]
2145+
>>> " foo ".split(maxsplit=0)
2146+
['foo ']
2147+
21362148

21372149
.. index::
21382150
single: universal newlines; str.splitlines method

0 commit comments

Comments
 (0)