wtfpython icon indicating copy to clipboard operation
wtfpython copied to clipboard

Unicode variable name surprises

Open doersino opened this issue 4 years ago • 2 comments

Utter madness.

>>> r = 1
>>> r
1
>>> 𝕣 = 2
>>> 𝕣
2
>>> r
2

I'm not sure why this is happening – not all non-ASCII characters in identifiers are translated into their closest ASCII match, but some are. This is in Python 3, of course, since Python 2 doesn't support these kinds of identifiers.

(It's entirely possible that this WTF is already in the document, I ctrlF'd for a few related terms but didn't find anything.)

doersino avatar May 15 '20 18:05 doersino

where is the issue?

Sasukethelast0 avatar Aug 30 '20 13:08 Sasukethelast0

r and 𝕣, while sort of representing the same character, are not the same symbols, so them resolving to the same internal value was a surprise to me. Other – not-fundamentally-different – combinations such as R and r or A and Å don't exhibit this behavior.

doersino avatar Aug 30 '20 14:08 doersino