unicode as valid naming symbols
rustompmody at gmail.com
Wed Mar 26 03:16:25 CET 2014
On Wednesday, March 26, 2014 12:22:40 AM UTC+5:30, wxjm... at gmail.com wrote:
> Le mardi 25 mars 2014 19:30:34 UTC+1, Mark H. Harris a écrit :
> > 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?
> > marcus
> >>> '√'.isidentifier()
> >>> 'λ'.isidentifier()
> >>> '$'.isidentifier()
> >>> '啕'.isidentifier()
> >>> 'a'.isidentifier()
> >>> '啕2z'.isidentifier()
> >>> print(''.isidentifier.__doc__)
> S.isidentifier() -> bool
> Return True if S is a valid identifier according
> to the language definition.
You obviously have more unicode knowledge than many (most?) of us here.
And when you contribute that knowledge in short-n-sweet form as above
it is helpful to all.
> cf "unicode.org" doc
Less helpful here.
What/where do you expect someone to start reading?
If a python beginner asks some basic question and someone here were to say
"Go read up on http://python.org"
who is helped?
More information about the Python-list