Skip to content

Commit 2866c43

Browse files
adorilsonhugovk
authored andcommitted
[3.14] gh-106318: Add examples for str.upper() method and improve related (GH-144638)
(cherry picked from commit 762b8ec) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent b970bcd commit 2866c43

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

‎Doc/builtins/stdtypes.rst‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,10 @@ expression support in the :mod:`re` module).
23582358
Return ``True`` if all cased characters [4]_ in the string are uppercase and
23592359
there is at least one cased character, ``False`` otherwise.
23602360

2361+
For example:
2362+
2363+
.. doctest::
2364+
23612365
>>> 'BANANA'.isupper()
23622366
True
23632367
>>> 'banana'.isupper()
@@ -2425,6 +2429,8 @@ expression support in the :mod:`re` module).
24252429
`described in section 3.13 'Default Case Folding' of the Unicode Standard
24262430
<https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G33992>`__.
24272431

2432+
See also :meth:`islower` and :meth:`upper`.
2433+
24282434

24292435
.. method:: str.lstrip(chars=None, /)
24302436

@@ -2916,15 +2922,33 @@ expression support in the :mod:`re` module).
29162922
.. method:: str.upper()
29172923

29182924
Return a copy of the string with all the cased characters [4]_ converted to
2919-
uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s``
2925+
uppercase.
2926+
2927+
For example:
2928+
2929+
.. doctest::
2930+
2931+
>>> 'Upper Method Example'.upper()
2932+
'UPPER METHOD EXAMPLE'
2933+
2934+
Note that ``s.upper().isupper()`` might be ``False`` if ``s``
29202935
contains no cased characters or if the Unicode category of the resulting
2921-
character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter,
2936+
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
29222937
titlecase).
29232938

2939+
For example, see the word "Python" written in Punjabi:
2940+
2941+
.. doctest::
2942+
2943+
>>> 'ازگر'.upper().isupper()
2944+
False
2945+
29242946
The uppercasing algorithm used is
29252947
`described in section 3.13 'Default Case Folding' of the Unicode Standard
29262948
<https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G33992>`__.
29272949

2950+
See also :meth:`isupper` and :meth:`lower`.
2951+
29282952

29292953
.. method:: str.zfill(width, /)
29302954

0 commit comments

Comments
 (0)