Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

On Fri, Aug 14, 2020 at 02:03:37PM +0000, Seth Woodworth wrote:

> I'm exploring what unicode code points can be used as valid starting 
> characters for identifiers.

I presume you have seen the documention here:

https://docs.python.org/3/reference/lexical_analysis.html#identifiers

> I'm looping over the code point ranges 
> with the XID_START property and attempting to add them to globals() to 
> see if they maintain the same representation.

You can add any hashable key to globals, it's just a dict:

    py> globals()[2] = 'test'
    py> globals()[2]
    'test'

Including strings that differ in their normalization:

    py> import unicodedata
    py> phi = 'ϕ'
    py> nphi = unicodedata.normalize('NFKC', phi)
    py> g = globals()
    py> g[phi] == g[nphi]
    False

The strings are only normalised when used as variables:

    py> eval(f'{phi} == {nphi}')
    True

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41542>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to