This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients ezio.melotti, sethwoodworth, steven.daprano, tianrluo, vstinner
Date 2020-08-15.05:31:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20200815053039.GT23924@ando.pearwood.info>
In-reply-to <1597413817.92.0.472445857575.issue41542@roundup.psfhosted.org>
Content
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
History
Date User Action Args
2020-08-15 05:31:31steven.dapranosetrecipients: + steven.daprano, vstinner, ezio.melotti, tianrluo, sethwoodworth
2020-08-15 05:31:31steven.dapranolinkissue41542 messages
2020-08-15 05:31:31steven.dapranocreate