[Python-ideas] π = math.pi

Ivan Levkivskyi levkivskyi at gmail.com
Fri Jun 2 18:48:35 EDT 2017


On 2 June 2017 at 12:17, Giampaolo Rodola' <g.rodola at gmail.com> wrote:

> On Thu, Jun 1, 2017 at 8:47 AM, Serhiy Storchaka <storchaka at gmail.com>
> wrote:
>
>> What you are think about adding Unicode aliases for some mathematic names
>> in the math module? ;-)
>>
>> math.π = math.pi
>> math.τ = math.tau
>> math.Γ = math.gamma
>> math.ℯ = math.e
>>
>> Unfortunately we can't use ∞, ∑ and √ as identifiers. :-(
>>
>> [...]
> * duplicated aliases might make sense if they add readability; in this
> case they don't unless (maybe) you have a mathematical background. I can
> infer what "math.gamma" stands for but not being a mathematician math.Γ
> makes absolutely zero sense to me.
>
>
There is a significant number of scientific Python programmers (21%
according to PyCharm 2016), so it is not that rare to meet someone who
knows what is Gamma function.
And for many of them π is much more readable than np.pi. Also there is
another problem, confusion between Gamma function and Euler–Mascheroni
constant, the first one is Γ,
the second one is γ (perfectly opposite to PEP 8 capitalization rules :-),
while both of them are frequently denoted as just gamma (in particular
math.gamma follows the PEP8 rules,
but is counter-intuitive for most scientist).

All that said, I agree that these problems are easily solved by a custom
import from. Still there is something in (or related to?) this proposal
I think is worth considering: Can we also allow identifiers like ∫ or √.
This will make many expressions more similar to usual TeX,
plus it will be useful for projects like SymPy.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170603/5639726d/attachment.html>


More information about the Python-ideas mailing list