Skip to content

gh-88341: Update docs for str title, istitle methods #26865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,15 @@ expression support in the :mod:`re` module).

Return ``True`` if the string is a titlecased string and there is at least one
character, for example uppercase characters may only follow uncased characters
and lowercase characters only cased ones. Return ``False`` otherwise.
(i.e. all that are not cased) and lowercase characters only follow cased [4]_ ones.
Return ``False`` otherwise.

Also see :meth:`title`.

.. note::

This method is different from the standard publishing definition
of a titlecased text fragment in which minor words would not be capitalized [6]_.


.. method:: str.isupper()
Expand Down Expand Up @@ -2122,8 +2130,8 @@ expression support in the :mod:`re` module).

.. method:: str.title()

Return a titlecased version of the string where words start with an uppercase
character and the remaining characters are lowercase.
Return a titlecased version of the string where words start with a titlecase
character (see :meth:`str.capitalize`) and the remaining characters are lowercase.

For example::

Expand All @@ -2149,6 +2157,12 @@ expression support in the :mod:`re` module).
>>> titlecase("they're bill's friends.")
"They're Bill's Friends."

.. note::

This method is different from the standard publishing definition
of a titlecased text fragment in which minor words would not be
capitalized [6]_.


.. method:: str.translate(table)

Expand Down Expand Up @@ -3235,6 +3249,11 @@ place, and instead produce new objects.
>>> b'Hello world'.istitle()
False

.. note::

This method is different from the standard publishing definition
of a titlecased text fragment in which minor words would not be capitalized [6]_.


.. method:: bytes.isupper()
bytearray.isupper()
Expand Down Expand Up @@ -3372,6 +3391,11 @@ place, and instead produce new objects.
The bytearray version of this method does *not* operate in place - it
always produces a new object, even if no changes were made.

.. note::

This method is different from the standard publishing definition
of a titlecased text fragment in which minor words would not be capitalized [6]_.


.. method:: bytes.upper()
bytearray.upper()
Expand Down Expand Up @@ -5371,3 +5395,5 @@ types, where they are relevant. Some of these are not reported by the

.. [5] To format only a tuple you should therefore provide a singleton tuple whose only
element is the tuple to be formatted.

.. [6] https://en.wikipedia.org/wiki/Title_case