Skip to content

gh-106318: Add example for str.isalpha() #137557

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 8 commits into
base: main
Choose a base branch
from
Open
Changes from 4 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
12 changes: 12 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,19 @@ expression support in the :mod:`re` module).
from the `Alphabetic property defined in the section 4.10 'Letters, Alphabetic, and
Ideographic' of the Unicode Standard
<https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-4/#G91002>`_.
For example::

..doctest::

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These conflict

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the missing space after .. ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can’t have both :: and the doctest. Look at what happens when you build it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got. Fixing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

>>> 'a commom word'.isalpha()
False
>>> 'acommomword'.isalpha()
True
>>> 'µ'.isalpha() # no-ascii characters could be alpha too
True


See Unicode Properties section in :ref:`unicode-howto`.
Copy link
Member

@StanFromIreland StanFromIreland Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which section exactly are you referring to? The description already covers the properties. Idea: It could be shown in the example, e.g.:

>>> import unicodedata
... unicodedata.category('é') 
'Ll'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which section exactly are you referring to?

https://docs.python.org/3/howto/unicode.html#unicode-properties

I couldn't link to the subsection. Now I discovered that :ref: role links to a label in the form .. _my-reference-label:, not to reStructuredText sections.

So, now I intend to put (adding this label on the Unicode Properties section)

See :ref:`unicode-properties`

I think this is more valuable than the example you suggested and a good complement to the description.

Shall I go ahead with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is done. Here and on #137592.


.. method:: str.isascii()

Expand Down
Loading