the meaning of rユ.......ï¾

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jul 23 12:53:49 EDT 2012


On Mon, 23 Jul 2012 15:52:32 +0200, Henrik Faber wrote:

> If you allow for UTF-8 identifiers you'll have to be horribly careful
> what to include and what to exclude. Is the non-breaking space a valid
> character for a identifier? Technically it's a different character than
> the normal space, so why shouldn't it be? What an awesome idea!

Because it's not a letter. Using Python 3:

py> nbs = '\N{NO-BREAK SPACE}'
py> import unicodedata
py> unicodedata.category(nbs)
'Zs'
py> unicodedata.category('a')
'Ll'


Not every character is valid in identifiers, not even in ASCII. Why would 
Unicode be any different?


Before Python added unicode identifiers, many issues were discussed and 
resolved. See the PEP that discusses it:

http://www.python.org/dev/peps/pep-3131/


> What about × vs x? 

No, because × is not a letter.

> Or Ì vs Í vs Î vs Ï vs Ĩ vs Ī vs ī vs Ĭ vs ... 

Yes, we get the point. Some letters look similar to other letters. Since 
these are all different letters, they are treated differently in 
identifiers, no differently from O vs 0 and I vs l vs 1.

Dyslexics will rightly complain that s and z look too similar, and b and 
d even more so. Perhaps they too should be banned from identifiers?



-- 
Steven



More information about the Python-list mailing list