Skip to content

Commit d7beb9c

Browse files
[3.13] 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>
1 parent a6f3b61 commit d7beb9c

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,9 @@ expression support in the :mod:`re` module).
24612461
:func:`re.split`). Splitting an empty string with a specified separator
24622462
returns ``['']``.
24632463

2464-
For example::
2464+
For example:
2465+
2466+
.. doctest::
24652467

24662468
>>> '1,2,3'.split(',')
24672469
['1', '2', '3']
@@ -2479,7 +2481,9 @@ expression support in the :mod:`re` module).
24792481
string or a string consisting of just whitespace with a ``None`` separator
24802482
returns ``[]``.
24812483

2482-
For example::
2484+
For example:
2485+
2486+
.. doctest::
24832487

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

2494-
For example::
2498+
For example:
2499+
2500+
.. doctest::
24952501

24962502
>>> "".split(None, 0)
24972503
[]
@@ -2500,7 +2506,7 @@ expression support in the :mod:`re` module).
25002506
>>> " foo ".split(maxsplit=0)
25012507
['foo ']
25022508

2503-
See also :meth:`join`.
2509+
See also :meth:`join` and :meth:`rsplit`.
25042510

25052511

25062512
.. index::

0 commit comments

Comments
 (0)