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

Marko Rauhamaa marko at pacujo.net
Sun Jul 3 05:01:51 EDT 2016


Lawrence D’Oliveiro <lawrencedo99 at gmail.com>:

> On Sunday, July 3, 2016 at 7:27:04 PM UTC+12, Marko Rauhamaa wrote:
>
>> Personally, I don't think even π should be used in identifiers.
>
> Why not?

1. It can't be typed easily.

2. It can look like an n.

3. Single-character identifiers should not be promoted, especially with
   a global scope.

> Python already has all the other single-character constants in what
> probably the most fundamental identity in all of mathematics:
>
>     $$e^{i \pi} + 1 = 0$$

Mathematics and physics have run into trouble with single-character
identifiers already. They have run out of letters and have had to reuse
them. Programmers used to have the same problem until they realized it's
ok to use descriptive names.

Just say,

    >>> import cmath
    >>> cmath.e ** (1j * cmath.pi) + 1
    1.2246467991473532e-16j


Marko



More information about the Python-list mailing list