https://github.com/python/cpython/commit/eed827ed091c6e55f11164046d287a76e30fbc0e
commit: eed827ed091c6e55f11164046d287a76e30fbc0e
branch: main
author: Blaise Pabon <bla...@gmail.com>
committer: hugovk <1324225+hug...@users.noreply.github.com>
date: 2025-06-13T11:54:16Z
summary:

gh-106318: Add example for `str.endswith()` (#134523)

Co-authored-by: Hugo van Kemenade <1324225+hug...@users.noreply.github.com>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 4854a2c077bb28..0954e3409a2dcc 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1863,7 +1863,19 @@ expression support in the :mod:`re` module).
    Return ``True`` if the string ends with the specified *suffix*, otherwise 
return
    ``False``.  *suffix* can also be a tuple of suffixes to look for.  With 
optional
    *start*, test beginning at that position.  With optional *end*, stop 
comparing
-   at that position.
+   at that position. Using *start* and *end* is equivalent to
+   ``str[start:end].endswith(suffix)``. For example::
+
+      >>> 'Python'.endswith('on')
+      True
+      >>> 'a tuple of suffixes'.endswith(('at', 'in'))
+      False
+      >>> 'a tuple of suffixes'.endswith(('at', 'es'))
+      True
+      >>> 'Python is amazing'.endswith('is', 0, 9)
+      True
+
+   See also :meth:`startswith` and :meth:`removesuffix`.
 
 
 .. method:: str.expandtabs(tabsize=8)

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to