Skip to content

Commit a77dde4

Browse files
miss-islingtonadorilsonvstinnerStanFromIreland
authored
[3.14] gh-106318: Improve str.rstrip() method doc (GH-143893) (#144699)
gh-106318: Improve str.rstrip() method doc (GH-143893) (cherry picked from commit 936d60d) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 7d07470 commit a77dde4

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Doc/library/stdtypes.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,21 +2630,27 @@ expression support in the :mod:`re` module).
26302630
Return a copy of the string with trailing characters removed. The *chars*
26312631
argument is a string specifying the set of characters to be removed. If omitted
26322632
or ``None``, the *chars* argument defaults to removing whitespace. The *chars*
2633-
argument is not a suffix; rather, all combinations of its values are stripped::
2633+
argument is not a suffix; rather, all combinations of its values are stripped.
2634+
For example:
2635+
2636+
.. doctest::
26342637

26352638
>>> ' spacious '.rstrip()
26362639
' spacious'
26372640
>>> 'mississippi'.rstrip('ipz')
26382641
'mississ'
26392642

2640-
See :meth:`str.removesuffix` for a method that will remove a single suffix
2643+
See :meth:`removesuffix` for a method that will remove a single suffix
26412644
string rather than all of a set of characters. For example::
26422645

26432646
>>> 'Monty Python'.rstrip(' Python')
26442647
'M'
26452648
>>> 'Monty Python'.removesuffix(' Python')
26462649
'Monty'
26472650

2651+
See also :meth:`strip`.
2652+
2653+
26482654
.. method:: str.split(sep=None, maxsplit=-1)
26492655

26502656
Return a list of the words in the string, using *sep* as the delimiter
@@ -2795,7 +2801,11 @@ expression support in the :mod:`re` module).
27952801
The *chars* argument is a string specifying the set of characters to be removed.
27962802
If omitted or ``None``, the *chars* argument defaults to removing whitespace.
27972803
The *chars* argument is not a prefix or suffix; rather, all combinations of its
2798-
values are stripped::
2804+
values are stripped.
2805+
2806+
For example:
2807+
2808+
.. doctest::
27992809

28002810
>>> ' spacious '.strip()
28012811
'spacious'
@@ -2806,12 +2816,17 @@ expression support in the :mod:`re` module).
28062816
from the string. Characters are removed from the leading end until
28072817
reaching a string character that is not contained in the set of
28082818
characters in *chars*. A similar action takes place on the trailing end.
2809-
For example::
2819+
2820+
For example:
2821+
2822+
.. doctest::
28102823

28112824
>>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
28122825
>>> comment_string.strip('.#! ')
28132826
'Section 3.2.1 Issue #32'
28142827

2828+
See also :meth:`rstrip`.
2829+
28152830

28162831
.. method:: str.swapcase()
28172832

0 commit comments

Comments
 (0)