https://github.com/python/cpython/commit/65acd016939d73e8d0530a9b933c0982de252844
commit: 65acd016939d73e8d0530a9b933c0982de252844
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-02-04T17:24:35Z
summary:

[3.13] gh-106318: Add examples for `str.startswith()` method (GH-144369) 
(#144480)

gh-106318: Add examples for `str.startswith()` method (GH-144369)
(cherry picked from commit 1b6d737ee0205521333cf5fe6ca6df2d3a6d4ec2)

Co-authored-by: Adorilson Bezerra <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 86a84faca97675..cca4ed1abdf545 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2510,6 +2510,19 @@ 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', 'a'))
+      True
+      >>> 'Python is amazing'.startswith('is', 7)
+      True
+
+   See also :meth:`endswith` and :meth:`removeprefix`.
+
 
 .. method:: str.strip(chars=None, /)
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to