Skip to content

Commit ae62d2b

Browse files
[3.14] gh-106318: Improve str.removeprefix() and str.removesuffix() docs (GH-143580) (#143614)
gh-106318: Improve str.removeprefix() and str.removesuffix() docs (GH-143580) Add doctest role and 'See also'. (cherry picked from commit 6d6c7ed) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 1d0baf1 commit ae62d2b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Doc/library/stdtypes.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,9 @@ expression support in the :mod:`re` module).
23692369

23702370
If the string starts with the *prefix* string, return
23712371
``string[len(prefix):]``. Otherwise, return a copy of the original
2372-
string::
2372+
string:
2373+
2374+
.. doctest::
23732375

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

23792381
.. versionadded:: 3.9
23802382

2383+
See also :meth:`removesuffix` and :meth:`startswith`.
2384+
23812385

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

23842388
If the string ends with the *suffix* string and that *suffix* is not empty,
23852389
return ``string[:-len(suffix)]``. Otherwise, return a copy of the
2386-
original string::
2390+
original string:
2391+
2392+
.. doctest::
23872393

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

23932399
.. versionadded:: 3.9
23942400

2401+
See also :meth:`removeprefix` and :meth:`endswith`.
2402+
23952403

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

0 commit comments

Comments
 (0)