<div>Having just discovered that PEP 3131 [1] enables me to use greek letters to</div><div>represent variables in equations, it was pointed out to me that it also allows</div><div>visually confusable characters in identifiers [2].</div>
<div><br></div><div>When I previously read the PEP I thought that the normalisation process</div><div>resolved these issues but now I see that the PEP leaves it as an open problem.</div><div>I also previously thought that the PEP would be irrelevant if I was using</div>
<div>ascii-only code but now I can see that if a GREEK CAPITAL LETTER ALPHA can</div><div>sneak into my code (just like those pesky tab characters) I could still have a</div><div>visually undetectable bug.</div><div><br></div>
<div>An example to show how an issue could arise:</div><div><br></div><div>"""</div><div>#!/usr/bin/env python3</div><div><br></div><div>code = '''</div><div>{0} = 123</div><div>{1} = 456</div><div>
print('"{0}" == "{1}":', "{0}" == "{1}")</div><div>print('{0} == {1}:', {0} == {1})</div><div>'''</div><div><br></div><div>def test_identifier(identifier1, identifier2):</div>
<div>    exec(code.format(identifier1, identifier2))</div><div><br></div><div>test_identifier('\u212b', '\u00c5') # Different Angstrom code points</div><div>test_identifier('A', '\u0391') # LATIN/GREEK CAPITAL A/ALPHA</div>
<div>"""</div><div><br></div><div>When I run this I get:</div><div><br></div><div>$ ./test.py</div><div>"Å" == "Å": False</div><div>Å == Å: True</div><div>"A" == "Α": False</div>
<div>A == Α: False</div><div><br></div><div>Is the proposal mentioned in the PEP (to use something based on Unicode</div><div>Technical Standard #39 [3]) something that might be implemented at any point?</div><div><br></div>
<div>Oscar</div><div><br></div><div>References:</div><div>[1] <a href="http://www.python.org/dev/peps/pep-3131/#open-issues">http://www.python.org/dev/peps/pep-3131/#open-issues</a></div><div>[2] <a href="http://article.gmane.org/gmane.comp.python.tutor/78116">http://article.gmane.org/gmane.comp.python.tutor/78116</a></div>
<div>[3] <a href="http://unicode.org/reports/tr39/#Confusable_Detection">http://unicode.org/reports/tr39/#Confusable_Detection</a></div>