From 946c44b352ce83683fe4ce9af10329d3292040ed Mon Sep 17 00:00:00 2001 From: Joey Smith Date: Tue, 13 May 2025 22:34:49 -0600 Subject: [PATCH 1/2] Document string split algorithm when sep is None and maxsplit is 0 --- Doc/library/stdtypes.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 1d9a655c7664ea..b6808669975c16 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -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 @@ -6040,3 +6052,4 @@ If you need to disable it entirely, set it to ``0``. .. [5] To format only a tuple you should therefore provide a singleton tuple whose only element is the tuple to be formatted. + From e0fbc46c472df606c1f9dcfbf4bb07c71322448f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 14 May 2025 05:38:44 -0400 Subject: [PATCH 2/2] Update Doc/library/stdtypes.rst Co-authored-by: Semyon Moroz --- Doc/library/stdtypes.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b6808669975c16..3486a18b5cb1f0 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -6052,4 +6052,3 @@ If you need to disable it entirely, set it to ``0``. .. [5] To format only a tuple you should therefore provide a singleton tuple whose only element is the tuple to be formatted. -