Skip to content

Commit 946c44b

Browse files
committed
Document string split algorithm when sep is None and maxsplit is 0
1 parent 9ad0c7b commit 946c44b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 13 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
@@ -6040,3 +6052,4 @@ If you need to disable it entirely, set it to ``0``.
60406052
60416053
.. [5] To format only a tuple you should therefore provide a singleton tuple whose only
60426054
element is the tuple to be formatted.
6055+

0 commit comments

Comments
 (0)