Skip to content

Commit b6299e8

Browse files
miss-islingtontmlnedbatdonBarbos
authored
[3.14] gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (GH-133987) (#133993)
--------- (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 4adb1dd commit b6299e8

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
@@ -2269,6 +2269,18 @@ expression support in the :mod:`re` module).
22692269
>>> ' 1 2 3 '.split()
22702270
['1', '2', '3']
22712271

2272+
If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only
2273+
leading runs of consecutive whitespace are considered.
2274+
2275+
For example::
2276+
2277+
>>> "".split(None, 0)
2278+
[]
2279+
>>> " ".split(None, 0)
2280+
[]
2281+
>>> " foo ".split(maxsplit=0)
2282+
['foo ']
2283+
22722284

22732285
.. index::
22742286
single: universal newlines; str.splitlines method

0 commit comments

Comments
 (0)