Skip to content

Commit 2658f4c

Browse files
hugovkadorilson
andauthored
[3.14] gh-106318: Add examples for str.upper() method and improve related (GH-144638) (#163077)
(cherry picked from commit 762b8ec) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent 993c82d commit 2658f4c

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()
@@ -2438,6 +2442,8 @@ expression support in the :mod:`re` module).
24382442
`described in section 3.13 'Default Case Folding' of the Unicode Standard
24392443
<https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G33992>`__.
24402444

2445+
See also :meth:`islower` and :meth:`upper`.
2446+
24412447

24422448
.. method:: str.lstrip(chars=None, /)
24432449

@@ -2929,15 +2935,33 @@ expression support in the :mod:`re` module).
29292935
.. method:: str.upper()
29302936

29312937
Return a copy of the string with all the cased characters [4]_ converted to
2932-
uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s``
2938+
uppercase.
2939+
2940+
For example:
2941+
2942+
.. doctest::
2943+
2944+
>>> 'Upper Method Example'.upper()
2945+
'UPPER METHOD EXAMPLE'
2946+
2947+
Note that ``s.upper().isupper()`` might be ``False`` if ``s``
29332948
contains no cased characters or if the Unicode category of the resulting
2934-
character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter,
2949+
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
29352950
titlecase).
29362951

2952+
For example, see the word "Python" written in Punjabi:
2953+
2954+
.. doctest::
2955+
2956+
>>> 'ازگر'.upper().isupper()
2957+
False
2958+
29372959
The uppercasing algorithm used is
29382960
`described in section 3.13 'Default Case Folding' of the Unicode Standard
29392961
<https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G33992>`__.
29402962

2963+
See also :meth:`isupper` and :meth:`lower`.
2964+
29412965

29422966
.. method:: str.zfill(width, /)
29432967

0 commit comments

Comments
 (0)