[Python-ideas] Allow using symbols from Unicode block "Superscripts and Subscripts" in identifiers
Chris Angelico
rosuav at gmail.com
Sat May 3 08:49:16 CEST 2014
On Sat, May 3, 2014 at 4:38 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Steven D'Aprano wrote:
>>
>> Particularly for mathematically-focused code, I think it would be useful
>> to be able to use identifiers like (say) σ² for variance,
>
>
> Having σ² be a variable name could be confusing. To a
> mathematician, it's not a distinct variable, it's
> just σ ** 2.
Maybe, but subscripts can be useful. Recently we were discussing
linear acceleration on python-list, and the way I learned the
principle (other people learned it with different letters) was:
Vₜ = V₀t + at²/2
which should translate into Python as:
Vₜ = V₀*t + a*t*t/2
(Not sure if people's fonts have all those characters; that's read
"V-t equals V-0 t plus a t squared over two".)
Being able to use subscripts in identifiers wouldn't be *often*
useful, but it would make direct translation from math to code a bit
easier.
ChrisA
More information about the Python-ideas
mailing list