On Sun, Nov 14, 2021 at 10:12:39PM -0800, Christopher Barker wrote:
> I am, however, surprised and disappointed by the NKFC normalization.
>
> For example, in writing math we often use different scripts to mean
> different things (e.g. TeX's Blackboard Bold). So if I were to use
> some of the Unicode Mathematical Alphanumeric Symbols, I wouldn't want
> them to get normalized.
Hmmm... would you really want these to all be different identifiers?
π π π© π B
You're assuming the reader of the code has the right typeface to view
them (rather than as mere boxes), and that their eyesight is good enough
to distinguish the variations even if their editor applies bold or
italic as part of syntax highlighting. That's very bold of you :-)
In any case, the question of NFKC versus NFC was certainly considered,
but unfortunately PEP 3131 doesn't document why NFKC was chosen.
https://www.python.org/dev/peps/pep-3131/
Before we change the normalisation rules, it would probably be a good
idea to trawl through the archives of the mailing list and work out why
NFKC was chosen in the first place, or contact Martin von LΓΆwis and see
if he remembers.
> Then there's the question of when this normalization happens (and when it
> doesn't). If one is doing any kind of metaprogramming, even just using
> getattr() and setattr(), things could get very confusing:
For ordinary identifiers, they are normalised at some point during
compilation or interpretation. It probably doesn't matter exactly when.
Strings should *not* be normalised when using subscripting on a dict,
not even on globals():
https://bugs.python.org/issue42680
I'm not sure about setattr and getattr. I think that they should be
normalised. But apparently they aren't:
>>> from types import SimpleNamespace
>>> obj = SimpleNamespace(B=1)
>>> setattr(obj, 'π', 2)
>>> obj
namespace(B=1, π=2)
>>> obj.B
1
>>> obj.π
1
See also here:
https://bugs.python.org/issue35105
--
Steve
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/7XZJPFED3YJSJ73YSPWCQPN6NLTNEMBI/
Code of Conduct: http://python.org/psf/codeofconduct/