From f2dd414ab0941112eaceeb7f885a285ebad1803a Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 12 May 2021 20:30:42 -0300 Subject: [PATCH 1/2] gh-106318: Add examples for str.startwith() method --- Doc/library/stdtypes.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ce0d7cbb2e4276..fbca076def9cd9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2735,6 +2735,21 @@ expression support in the :mod:`re` module). test string beginning at that position. With optional *end*, stop comparing string at that position. + For example: + + .. doctest:: + + >>> 'Python'.startswith('Py') + True + >>> 'a tuple of prefixes'.startswith(('at', 'in')) + False + >>> 'a tuple of prefixes'.startswith(('at', 'a')) + True + >>> 'Python is amazing'.startswith('is', 7) + True + + See also :meth:`endswith` and :meth:`removeprefix`. + .. method:: str.strip(chars=None, /) From 7858b4163027decddfc0290812fad9486d4e65b9 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Wed, 4 Feb 2026 09:52:57 +0000 Subject: [PATCH 2/2] gh-106318: Remove an example from str.startswith() method documentation Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/stdtypes.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index fbca076def9cd9..7f6968bc8ef605 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2741,8 +2741,6 @@ expression support in the :mod:`re` module). >>> 'Python'.startswith('Py') True - >>> 'a tuple of prefixes'.startswith(('at', 'in')) - False >>> 'a tuple of prefixes'.startswith(('at', 'a')) True >>> 'Python is amazing'.startswith('is', 7)