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

[3.14] gh-106318: Improve str.removeprefix() and str.removesuffix() docs (GH-143580) by miss-islington · Pull Request #143614 · 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
12 changes: 10 additions & 2 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 @@ -2369,7 +2369,9 @@ expression support in the :mod:`re` module).

If the string starts with the *prefix* string, return
``string[len(prefix):]``. Otherwise, return a copy of the original
string::
string:

.. doctest::

>>> 'TestHook'.removeprefix('Test')
'Hook'
Expand All @@ -2378,12 +2380,16 @@ expression support in the :mod:`re` module).

.. versionadded:: 3.9

See also :meth:`removesuffix` and :meth:`startswith`.


.. method:: str.removesuffix(suffix, /)

If the string ends with the *suffix* string and that *suffix* is not empty,
return ``string[:-len(suffix)]``. Otherwise, return a copy of the
original string::
original string:

.. doctest::

>>> 'MiscTests'.removesuffix('Tests')
'Misc'
Expand All @@ -2392,6 +2398,8 @@ expression support in the :mod:`re` module).

.. versionadded:: 3.9

See also :meth:`removeprefix` and :meth:`endswith`.


.. method:: str.replace(old, new, /, count=-1)

Expand Down
Loading

Back | FazBrowse Home | New Git URL