Skip to content

Commit b9fdcf0

Browse files
committed
WIP
1 parent fce5e98 commit b9fdcf0

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Doc/reference/lexical_analysis.rst

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,28 @@ characters:
516516
Non-ASCII characters in names
517517
-----------------------------
518518

519-
Besides ``A-Z``, ``a-z``, ``_`` and ``0-9``, names can use "letter-like"
520-
and "number-like" characters from outside the ASCII range,
521-
as detailed in this section.
519+
Python identifiers may contain all sorts of characters.
520+
For example, ``ř_1``, ````, or ``साँप`` are valid identifiers.
521+
However, ``r〰2``, ````, or ``🐍`` are not.
522+
Additionally, some variations are considered equivalent: for example,
523+
``fi`` (2 letters) and ```` (1 ligature).
524+
525+
526+
A :ref:`name token <identifiers>` that only contains ASCII characters
527+
(``A-Z``, ``a-z``, ``_`` and ``0-9``) is always valid, and distinct from
528+
different ASCII-only names.
529+
The rules are somewhat more complicated when using non-ASCII characters.
530+
531+
Informally, all names must be composed of letters, digits, numbers and
532+
underscores, and cannot start with a digit.
533+
534+
535+
536+
537+
Besides ``A-Z``, ``a-z``, ``_`` and ``0-9``, names can use characters
538+
from outside the ASCII range.
539+
540+
, as detailed in this section.
522541

523542
All names are converted into the `normalization form`_ NFKC while parsing.
524543
This means that, for example, some typographic variants of characters are
@@ -538,6 +557,9 @@ converted to their "basic" form. For example, ``nᵘₘᵇₑʳ`` normalizes to
538557
:func:`globals` dictionary as ``globals()["number"]`` but not
539558
``globals()["nᵘₘᵇₑʳ"]``.
540559

560+
Similarly to how ASCII-only names must contain only letters, numbers and
561+
the underscore, and cannot start with a digit, the normalized name must
562+
541563
The first character of a normalized identifier must be "letter-like".
542564
Formally, this means it must belong to the set ``id_start``,
543565
which is defined as the union of:

0 commit comments

Comments
 (0)