Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-106318: Add doctest role and a 'See also' to the str.split() docs (
GH-144367)

(cherry picked from commit a96cba5)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
  • Loading branch information
adorilson authored and miss-islington committed Jun 4, 2026
commit c667778207c410f8e19b32ec66c08d1a2a2f9fb5
14 changes: 10 additions & 4 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2612,7 +2612,9 @@ expression support in the :mod:`re` module).
:func:`re.split`). Splitting an empty string with a specified separator
returns ``['']``.

For example::
For example:

.. doctest::

>>> '1,2,3'.split(',')
['1', '2', '3']
Expand All @@ -2630,7 +2632,9 @@ expression support in the :mod:`re` module).
string or a string consisting of just whitespace with a ``None`` separator
returns ``[]``.

For example::
For example:

.. doctest::

>>> '1 2 3'.split()
['1', '2', '3']
Expand All @@ -2642,7 +2646,9 @@ expression support in the :mod:`re` module).
If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only
leading runs of consecutive whitespace are considered.

For example::
For example:

.. doctest::

>>> "".split(None, 0)
[]
Expand All @@ -2651,7 +2657,7 @@ expression support in the :mod:`re` module).
>>> " foo ".split(maxsplit=0)
['foo ']

See also :meth:`join`.
See also :meth:`join` and :meth:`rsplit`.


.. index::
Expand Down
Loading