Add Standard String Literals and Prefixes for Mathematical Notation
I love regular expressions. I would love to see Bra-Ket notation and many of the popular mathematical forms commonly practiced in engineering and science supported by the Python language in an expressive and logical way. I feel the need for expressing mathematical concepts in a standardized and sightly way, beyond just being able to use Unicode equivalents of mathematical symbols, would be an enormous functional benefit.
Can you provide short, but non-trivial, clear examples of "before" (current Python) and "after" (what you propose it looks like) to demonstrate the advantage? Will it be ambiguous with existing syntax? On Tue, Feb 25, 2020 at 6:10 PM Nathan Edwards <nathan.w.edwards@outlook.com> wrote:
I love regular expressions. I would love to see Bra-Ket notation and many of the popular mathematical forms commonly practiced in engineering and science supported by the Python language in an expressive and logical way. I feel the need for expressing mathematical concepts in a standardized and sightly way, beyond just being able to use Unicode equivalents of mathematical symbols, would be an enormous functional benefit. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/HDES3Q... Code of Conduct: http://python.org/psf/codeofconduct/
Hi Nathan, On Tue, Feb 25, 2020 at 11:58:58PM +0000, Nathan Edwards wrote:
I love regular expressions.
Regexes' terse syntax are normally considered rather the opposite of Pythonic.
I would love to see Bra-Ket notation and many of the popular mathematical forms commonly practiced in engineering and science supported by the Python language in an expressive and logical way. I feel the need for expressing mathematical concepts in a standardized and sightly way, beyond just being able to use Unicode equivalents of mathematical symbols, would be an enormous functional benefit.
You might find more interest if you make some concrete proposals rather than a vague, generic request for more mathematical syntax. Also keep in mind that Python is not a specialised language for mathematics. Its a generic language for everyone, which means the standard is "will the average programmer be able to read this?" not "will mathematicians be familiar with this syntax?". For example, the function for calculating standard deviation is written `statistics.stdev` not `σ`. -- Steven
For example, the function for calculating standard deviation is written
`statistics.stdev` not `σ`.
What do you mean?
from statistics import stdev as σ σ([5, 6, 4, 6, 3, 7]) 1.4719601443879744
:-) -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
On Tue, Feb 25, 2020 at 10:08:57PM -0500, David Mertz wrote:
from statistics import stdev as σ σ([5, 6, 4, 6, 3, 7]) 1.4719601443879744
:-)
You know what you've done now, don't you? Somebody is going to propose a whole series of aliased names for statistics and math modules: Σ = sum σ = statistics.stdev μ = statistics.mean Π = math.prod γ = math.gamma etc. -- Steven
On Wed, Feb 26, 2020 at 3:43 PM Steven D'Aprano <steve@pearwood.info> wrote:
On Tue, Feb 25, 2020 at 10:08:57PM -0500, David Mertz wrote:
from statistics import stdev as σ σ([5, 6, 4, 6, 3, 7]) 1.4719601443879744
:-)
You know what you've done now, don't you? Somebody is going to propose a whole series of aliased names for statistics and math modules:
Σ = sum σ = statistics.stdev μ = statistics.mean Π = math.prod γ = math.gamma
etc.
Stick it up on PyPI. You "from blackboard import *" and then proceed to use all those symbols freely. Of course, things could get a little difficult when one symbol has multiple meanings, but version 2.0 of the module will have not just aliases, but magic objects that figure out from context what the meaning is supposed to be. ChrisA
(Un)Happily we have the keyword "as" already. They can make their own aliases. On Tue, Feb 25, 2020, 11:46 PM Steven D'Aprano <steve@pearwood.info> wrote:
On Tue, Feb 25, 2020 at 10:08:57PM -0500, David Mertz wrote:
from statistics import stdev as σ σ([5, 6, 4, 6, 3, 7]) 1.4719601443879744
:-)
You know what you've done now, don't you? Somebody is going to propose a whole series of aliased names for statistics and math modules:
Σ = sum σ = statistics.stdev μ = statistics.mean Π = math.prod γ = math.gamma
etc.
-- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/A4KGHR... Code of Conduct: http://python.org/psf/codeofconduct/
participants (5)
-
Chris Angelico
-
David Mertz
-
Nathan Edwards
-
Nick Timkovich
-
Steven D'Aprano