[Python-ideas] π = math.pi
Steven D'Aprano
steve at pearwood.info
Sat Jun 3 12:48:24 EDT 2017
On Sun, Jun 04, 2017 at 02:36:50AM +1000, Steven D'Aprano wrote:
> But Python 3.5 does treat it as an identifier!
>
> py> ℘ = 1 # should be a SyntaxError ?
> py> ℘
> 1
>
> There's a bug here, somewhere, I'm just not sure where...
That appears to be the only Symbol Math character which is accepted as
an identifier in Python 3.5:
py> import unicodedata
py> all_unicode = map(chr, range(0x110000))
py> symbols = [c for c in all_unicode if unicodedata.category(c) == 'Sm']
py> len(symbols)
948
py> ns = {}
py> for c in symbols:
... try:
... exec(c + " = 1", ns)
... except SyntaxError:
... pass
... else:
... print(c, unicodedata.name(c))
...
℘ SCRIPT CAPITAL P
py>
--
Steve
More information about the Python-ideas
mailing list