From 37cef7e6235642f06879c3f6662faace8cb6a1c8 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 8 Jan 2026 19:33:30 +0000 Subject: [PATCH 1/2] gh-106318: Add doctest role and 'See also' for str.removeprefix() --- Doc/library/stdtypes.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ae197f765d1e16..b28eb787f73b2e 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -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' @@ -2378,6 +2380,8 @@ expression support in the :mod:`re` module). .. versionadded:: 3.9 + See also :meth:`removesuffix` and :meth:`startswith`. + .. method:: str.removesuffix(suffix, /) From 3eb32bd4b8befaf9dc68e72fa0959330aac9b247 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 8 Jan 2026 19:48:56 +0000 Subject: [PATCH 2/2] gh-106318: Add doctest role and 'See also' for str.removesuffix() --- Doc/library/stdtypes.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b28eb787f73b2e..5276860d6bbfdf 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2387,7 +2387,9 @@ expression support in the :mod:`re` module). 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' @@ -2396,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)