Skip to content

Commit 3e23047

Browse files
tmlnedbatdonBarbos
authored
gh-133986: Document string split algorithm when sep is None and maxsplit is 0 (#133987)
* 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>
1 parent 6df3976 commit 3e23047

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)