mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Doc: Fix alphabetical ordering of removeprefix/suffix. (GH-22194)
(cherry picked from commit 3304cbd990
)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
This commit is contained in:
parent
1b4bdb4cd7
commit
7af6bf4dad
1 changed files with 28 additions and 27 deletions
|
@ -1547,33 +1547,6 @@ expression support in the :mod:`re` module).
|
||||||
interpreted as in slice notation.
|
interpreted as in slice notation.
|
||||||
|
|
||||||
|
|
||||||
.. method:: str.removeprefix(prefix, /)
|
|
||||||
|
|
||||||
If the string starts with the *prefix* string, return
|
|
||||||
``string[len(prefix):]``. Otherwise, return a copy of the original
|
|
||||||
string::
|
|
||||||
|
|
||||||
>>> 'TestHook'.removeprefix('Test')
|
|
||||||
'Hook'
|
|
||||||
>>> 'BaseTestCase'.removeprefix('Test')
|
|
||||||
'BaseTestCase'
|
|
||||||
|
|
||||||
.. versionadded:: 3.9
|
|
||||||
|
|
||||||
.. 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::
|
|
||||||
|
|
||||||
>>> 'MiscTests'.removesuffix('Tests')
|
|
||||||
'Misc'
|
|
||||||
>>> 'TmpDirMixin'.removesuffix('Tests')
|
|
||||||
'TmpDirMixin'
|
|
||||||
|
|
||||||
.. versionadded:: 3.9
|
|
||||||
|
|
||||||
|
|
||||||
.. method:: str.encode(encoding="utf-8", errors="strict")
|
.. method:: str.encode(encoding="utf-8", errors="strict")
|
||||||
|
|
||||||
Return an encoded version of the string as a bytes object. Default encoding
|
Return an encoded version of the string as a bytes object. Default encoding
|
||||||
|
@ -1888,6 +1861,34 @@ expression support in the :mod:`re` module).
|
||||||
the string itself, followed by two empty strings.
|
the string itself, followed by two empty strings.
|
||||||
|
|
||||||
|
|
||||||
|
.. method:: str.removeprefix(prefix, /)
|
||||||
|
|
||||||
|
If the string starts with the *prefix* string, return
|
||||||
|
``string[len(prefix):]``. Otherwise, return a copy of the original
|
||||||
|
string::
|
||||||
|
|
||||||
|
>>> 'TestHook'.removeprefix('Test')
|
||||||
|
'Hook'
|
||||||
|
>>> 'BaseTestCase'.removeprefix('Test')
|
||||||
|
'BaseTestCase'
|
||||||
|
|
||||||
|
.. versionadded:: 3.9
|
||||||
|
|
||||||
|
|
||||||
|
.. 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::
|
||||||
|
|
||||||
|
>>> 'MiscTests'.removesuffix('Tests')
|
||||||
|
'Misc'
|
||||||
|
>>> 'TmpDirMixin'.removesuffix('Tests')
|
||||||
|
'TmpDirMixin'
|
||||||
|
|
||||||
|
.. versionadded:: 3.9
|
||||||
|
|
||||||
|
|
||||||
.. method:: str.replace(old, new[, count])
|
.. method:: str.replace(old, new[, count])
|
||||||
|
|
||||||
Return a copy of the string with all occurrences of substring *old* replaced by
|
Return a copy of the string with all occurrences of substring *old* replaced by
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue