Skip to content

Commit 1b50604

Browse files
committed
gh-106318: Add doctest role and a 'See also' item for str.split()
1 parent ccbe41e commit 1b50604

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Doc/library/stdtypes.rst

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

2623-
For example::
2623+
For example:
2624+
2625+
.. doctest::
26242626

26252627
>>> '1,2,3'.split(',')
26262628
['1', '2', '3']
@@ -2638,7 +2640,9 @@ expression support in the :mod:`re` module).
26382640
string or a string consisting of just whitespace with a ``None`` separator
26392641
returns ``[]``.
26402642

2641-
For example::
2643+
For example:
2644+
2645+
.. doctest::
26422646

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

2653-
For example::
2657+
For example:
2658+
2659+
.. doctest::
26542660

26552661
>>> "".split(None, 0)
26562662
[]
@@ -2659,7 +2665,7 @@ expression support in the :mod:`re` module).
26592665
>>> " foo ".split(maxsplit=0)
26602666
['foo ']
26612667

2662-
See also :meth:`join`.
2668+
See also :meth:`join` and :meth:`rsplit`.
26632669

26642670

26652671
.. index::

0 commit comments

Comments
 (0)