https://github.com/python/cpython/commit/bdd3f1cf7d200a2c75e50bd432bc02c47eaab3e0
commit: bdd3f1cf7d200a2c75e50bd432bc02c47eaab3e0
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: encukou <[email protected]>
date: 2026-11-04T17:55:01+01:00
summary:

[3.15] gh-106318: Add an example for `str.capitalize()` (GH-134272) (GH-161325)

(cherry picked from commit c3e24227320515456dc8a9e1cb88503fab5d0191)

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

files:
M Doc/builtins/stdtypes.rst

diff --git a/Doc/builtins/stdtypes.rst b/Doc/builtins/stdtypes.rst
index 3652ccf8b28d7ba..d104d11647d70ee 100644
--- a/Doc/builtins/stdtypes.rst
+++ b/Doc/builtins/stdtypes.rst
@@ -2129,13 +2129,23 @@ expression support in the :mod:`re` module).
 .. method:: str.capitalize()
 
    Return a copy of the string with its first character capitalized and the
-   rest lowercased.
+   rest lowercased. For example:
+
+   .. doctest::
+
+      >>> 'PYTHON IS AMAZING'.capitalize()
+      'Python is amazing'
+      >>> 'Njemačka starts With a non-ASCII digraph'.capitalize()
+      'Njemačka starts with a non-ascii digraph'
+
+   See also :meth:`title`.
 
    .. versionchanged:: 3.8
       The first character is now put into titlecase rather than uppercase.
       This means that characters like digraphs will only have their first
       letter capitalized, instead of the full character.
 
+
 .. method:: str.casefold()
 
    Return a casefolded copy of the string. Casefolded strings may be used for

_______________________________________________
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