Well, I finally ran into a Python Unicode problem, sort of

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Sun Jul 3 03:29:40 EDT 2016


John Ladasky writes:

[- -]

> The nabla symbol (∇) is used in the naming of gradients.  Python isn't
> having it.  The interpreter throws a "SyntaxError: invalid character
> in identifier" when it encounters the ∇.
>
> I am now wondering what constitutes a valid character for an
> identifier, and how they were chosen.  Obviously, the Western alphabet
> and standard Greek letters work.  I just tried a few very weird
> characters from the Latin Extended range, and some Cyrillic
> characters.  These are also fine.

I think they merely extended the identifier syntax to Unicode: one or
more letters, underscores and digits, not starting with a digit. The
nabla symbol is not classified as a letter in Unicode, so it's not
allowed under this rule, and there is no other rule to allow it.

(Hm. Python seems to understand that the character occurs in what is
intended to be an identifier. Perhaps that's a default error message.)



More information about the Python-list mailing list