FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.14] gh-106318: Improve str.rstrip() method doc (GH-143893) by miss-islington · Pull Request #144699 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
23 changes: 19 additions & 4 deletions Doc/library/stdtypes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2630,21 +2630,27 @@ expression support in the :mod:`re` module).
Return a copy of the string with trailing characters removed. The *chars*
argument is a string specifying the set of characters to be removed. If omitted
or ``None``, the *chars* argument defaults to removing whitespace. The *chars*
argument is not a suffix; rather, all combinations of its values are stripped::
argument is not a suffix; rather, all combinations of its values are stripped.
For example:

.. doctest::

>>> ' spacious '.rstrip()
' spacious'
>>> 'mississippi'.rstrip('ipz')
'mississ'

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

>>> 'Monty Python'.rstrip(' Python')
'M'
>>> 'Monty Python'.removesuffix(' Python')
'Monty'

See also :meth:`strip`.


.. method:: str.split(sep=None, maxsplit=-1)

Return a list of the words in the string, using *sep* as the delimiter
Expand Down Expand Up @@ -2795,7 +2801,11 @@ expression support in the :mod:`re` module).
The *chars* argument is a string specifying the set of characters to be removed.
If omitted or ``None``, the *chars* argument defaults to removing whitespace.
The *chars* argument is not a prefix or suffix; rather, all combinations of its
values are stripped::
values are stripped.

For example:

.. doctest::

>>> ' spacious '.strip()
'spacious'
Expand All @@ -2806,12 +2816,17 @@ expression support in the :mod:`re` module).
from the string. Characters are removed from the leading end until
reaching a string character that is not contained in the set of
characters in *chars*. A similar action takes place on the trailing end.
For example::

For example:

.. doctest::

>>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
>>> comment_string.strip('.#! ')
'Section 3.2.1 Issue #32'

See also :meth:`rstrip`.


.. method:: str.swapcase()

Expand Down
Loading

Back | FazBrowse Home | New Git URL