[issue42680] unicode identifiers not accessible or assignable through globals()

2021-01-20 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue42680] unicode identifiers not accessible or assignable through globals()

2020-12-20 Thread Eric V. Smith
Eric V. Smith added the comment: I think documenting this with globals() and locals() is a good idea. That's the place this is most likely to trip someone up. -- nosy: +eric.smith ___ Python tracker ___

[issue42680] unicode identifiers not accessible or assignable through globals()

2020-12-18 Thread Martin Chase
Martin Chase added the comment: Ah! So then the proper code for me would be e.g.: ``` >>> globals()[unicodedata.normalize("NFKC", "µmeow")] 1e-06 ``` Yes, it's clear when I read https://www.python.org/dev/peps/pep-3131/ that the normalization is going to happen. Is it also worth adding a note

[issue42680] unicode identifiers not accessible or assignable through globals()

2020-12-18 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm pretty sure this is not a bug, but is working as designed. The interpreter normalises unicode identifiers, but key lookup in the dict does not. Sorry, I don't have time right now to give a more detailed answer, but there are two distinct mu characters:

[issue42680] unicode identifiers not accessible or assignable through globals()

2020-12-18 Thread Martin Chase
Martin Chase added the comment: Oh, I just gave a cursory using `locals()`, and the same misbehavior is present. A workaround, for anyone needing to assign or access unicode globals, is to use `exec`, e.g. `exec("µmeow = 1e-6", globals())`. -- ___

[issue42680] unicode identifiers not accessible or assignable through globals()

2020-12-18 Thread Martin Chase
New submission from Martin Chase : This behavior is best described by the code below: ``` >>> meow = 1 >>> 'meow' in globals() True >>> µmeow = 1e-6 >>> 'µmeow' in globals() False >>> globals()['woof'] = 1 >>> woof 1 >>> globals()['µwoof'] = 1e-6 >>> µwoof Traceback (most recent call last): Fi