FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106318: Add examples for str.upper() method and improve related by adorilson · Pull Request #144638 · python/cpython · GitHub

Repository navigation

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
30 changes: 28 additions & 2 deletions Doc/library/stdtypes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2374,6 +2374,10 @@ expression support in the :mod:`re` module).
Return ``True`` if all cased characters [4]_ in the string are uppercase and
there is at least one cased character, ``False`` otherwise.

For example:

.. doctest::

>>> 'BANANA'.isupper()
True
>>> 'banana'.isupper()
Expand All @@ -2383,6 +2387,7 @@ expression support in the :mod:`re` module).
>>> ' '.isupper()
False

See also :meth:`islower` and :meth:`upper`.


.. _meth-str-join:
Expand Down Expand Up @@ -2438,6 +2443,8 @@ expression support in the :mod:`re` module).
Conversion' of the Unicode Standard
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G34078>`__.

See also :meth:`islower` and :meth:`upper`.


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

Expand Down Expand Up @@ -2877,15 +2884,34 @@ expression support in the :mod:`re` module).
.. method:: str.upper()

Return a copy of the string with all the cased characters [4]_ converted to
uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s``
uppercase.

For example:

.. doctest::

>>> 'Upper Method Example'.upper()
'UPPER METHOD EXAMPLE'

Note that ``s.upper().isupper()`` might be ``False`` if ``s``
contains uncased characters or if the Unicode category of the resulting
character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter,
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
titlecase).

For example, see the word "Python" written in Punjabi, the most spoken language
in Pakistan:

.. doctest::

>>> 'ازگر'.upper().isupper()
False

The uppercasing algorithm used is `described in section 3.13.2 'Default Case
Conversion' of the Unicode Standard
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G34078>`__.

See also :meth:`isupper` and :meth:`lower`.


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

Expand Down
Loading

Back | FazBrowse Home | New Git URL