Skip to content

gh-127833: lexical analysis: Improve section on Names #131474

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 3 commits into
base: main
Choose a base branch
from

Conversation

encukou
Copy link
Member

@encukou encukou commented Mar 19, 2025

Use consistent terminology: "names" are "identifiers", "keywords", and "soft keywords".
Start with the simple case (ASCII), then get more and more technical.
Define NAME in the formal lexical grammar.
Exclude keywords in the identifier definition.


📚 Documentation preview 📚: https://cpython-previews--131474.org.readthedocs.build/

Comment on lines 342 to 343
16.0.0 can be found at
https://www.unicode.org/Public/16.0.0/ucd/DerivedCoreProperties.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the link could be moved below too? Inline links are nice ;-)

Comment on lines +284 to +285
include the uppercase and lowercase letters (``A`` through ``Z`` and ``a`` to
``z``), the underscore ``_`` and, except for the first character, the digits
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
include the uppercase and lowercase letters (``A`` through ``Z`` and ``a`` to
``z``), the underscore ``_`` and, except for the first character, the digits
include the uppercase and lowercase letters, the underscore ``_`` and, except
for the first character, the digits

Do we really need to explain this here too?

This is just below:

Besides A-Z, a-z, _ and 0-9 ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd definitely keep it here; making it clear that “letters in the ASCII range” is A-Z and a-z.
Perhaps shorten it:

Suggested change
include the uppercase and lowercase letters (``A`` through ``Z`` and ``a`` to
``z``), the underscore ``_`` and, except for the first character, the digits
include the uppercase and lowercase letters (``A-Z`` and ``a-z``),
the underscore ``_`` and, except for the first character, the digits

I'd be OK with deduplicating the later occurence, but something like “ASCII characters as listed above” is almost as long as repeating the lists. This isn't code, it can be a little WET.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be better :-)

in (`id_start` `xid_continue`*)">
xid_continue: <all characters in `id_continue` whose NFKC normalization is
in (`id_continue`*)">
identifier: <`NAME`, except keywords>

A non-normative HTML file listing all valid identifier characters for Unicode
16.0.0 can be found at
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
16.0.0 can be found at
15.1.0 can be found at

Unicode categories use the version of the Unicode Character Database as
included in the :mod:unicodedata module.

According to the docs that is 15.1.0 at the moment, maybe we should link to that one instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh apologies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants