On 2014-03-25 18:30, Mark H Harris wrote:
greetings, I would like to create a lamda as follows:
√ = lambda n: sqrt(n)
On my keyboard mapping the "problem" character is alt-v which produces
the radical symbol. When trying to set the symbol as a name within the
name-space gives a syntax error:
>>> from math import sqrt
>>>
>>> √ = lambda n: sqrt(n)
SyntaxError: invalid character in identifier
>>>
>>>
however this works:
>>>
>>> λ = lambda n: sqrt(n)
>>>
>>> λ(2)
1.4142135623730951
>>>
The question is which unicode(s) are capable of being proper name
characters, and which ones are off-limits, and why?
It's explained in PEP 3131.
Basically, a name should to start with a letter (this has been extended
to include Chinese characters, etc) or an underscore.
λ is a classified as Lowercase_Letter.
√ is classified as Math_Symbol.
--
https://mail.python.org/mailman/listinfo/python-list