https://github.com/python/cpython/commit/c260ed15d1319e392e15ca9eef48d3adc0a36419
commit: c260ed15d1319e392e15ca9eef48d3adc0a36419
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2025-06-13T15:13:59+03:00
summary:

[3.13] gh-106318: Add example for `str.endswith()` (GH-134523) (#135460)

gh-106318: Add example for `str.endswith()` (GH-134523)
(cherry picked from commit eed827ed091c6e55f11164046d287a76e30fbc0e)

Co-authored-by: Blaise Pabon <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index a32dee4ca5727e..7fe33d44b3a6d6 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1727,7 +1727,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 -- [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