0

Could someone explain why mathematical variables are allowed, but emoji variables are not?

>>> π = 3.14
>>> π
3.14
>>>  = 2
  File "<stdin>", line 1
     = 2
    ^
SyntaxError: invalid character in identifier
Joep
  • 788
  • 2
  • 8
  • 23
  • 5
    https://docs.python.org/3/reference/lexical_analysis.html#identifiers – jonrsharpe Sep 27 '21 at 10:30
  • 1
    To expand on @jonrsharpe's comment, because `unicodedata.category('')` is `'So'`, which isn't valid. – AKX Sep 27 '21 at 10:31
  • 4
    `π` is not a "mathematical variables" but a _letter_, although in a different alphabet. `` is not. – tobias_k Sep 27 '21 at 10:33
  • 1
    Note _normalisation_ can also create problems with dynamic access when using a broader character set for variable names, see e.g. https://stackoverflow.com/q/48063082/3001761. Sticking to ASCII is probably easier. – jonrsharpe Sep 27 '21 at 10:34
  • [Unicode identifiers in Python?](https://stackoverflow.com/a/21867836/3890632) – khelwood Sep 27 '21 at 10:43

0 Answers0