anon
anon

Reputation:

How to know if a Unicode identifier is valid?

Here is a sample scenario -

>>> এক = 1
>>> ১ = 1
  File "<stdin>", line 1
    ১ = 1
      ^
SyntaxError: invalid character in identifier

I'm running this from default python3 interpreter. Why do the first unicode string work as an identifier and not the second one?

Upvotes: 4

Views: 190

Answers (1)

Simeon Visser
Simeon Visser

Reputation: 122456

Valid identifiers are explained in the Python 3 documentation: Lexical analysis - Identifiers and keywords.

The exact details can found in PEP 3131.

Upvotes: 2

Related Questions