[Python-ideas] π = math.pi
Steven D'Aprano
steve at pearwood.info
Fri Jun 2 20:10:26 EDT 2017
On Fri, Jun 02, 2017 at 04:29:16PM -0700, Guido van Rossum wrote:
> Are those characters not considered Unicode letters? Maybe we could add
> their category to the allowed set?
They're not letters:
py> {unicodedata.category(c) for c in '∑√∫∞'}
{'Sm'}
That's Symbol, Math.
One problem is that the 'Sm' category includes a whole lot of
mathematical symbols that we probably don't want in identifiers:
∴ ∣ ≈ ≒ ≝ ≫ ≮ ⊞ (plus MANY more variations on = < and > operators)
including some "Confusables":
∁ ∊ ∨ ∗ ∑ etc
C ε v * Σ
http://www.unicode.org/reports/tr39/
Of course a language can define identifiers however it likes, but I
think it is relevant that the Unicode Consortium's default algorithm for
determining an identifier excludes Sm.
http://www.unicode.org/reports/tr31/
I also disagree with Ivan that these symbols would be particularly
useful in general, even for maths-heavy code, although I wouldn't say no
to special casing ∞ (infinity) and maybe √ as a unary square root
operator.
--
Steve
More information about the Python-ideas
mailing list