[Python-ideas] Verbatim names (allowing keywords as names)

Stephan Houben stephanh42 at gmail.com
Fri May 18 09:09:57 EDT 2018


2018-05-18 13:37 GMT+02:00 Steven D'Aprano <steve at pearwood.info>:

> On Fri, May 18, 2018 at 11:17:13AM +0200, Stephan Houben wrote:
>
> > And the alternative is to replace all occurrences of
> > spam with 𝐬𝐩𝐚𝐦 , which has the same effect and also is
> > backward-compatible with 3.x for x < 8.
> >
> > So there is already a kind of solution available, albeit an ugly one.
>
> You are kidding, I hope.
>


I am not kidding; I am merely defending the status quo.
I demonstrate how the intended behavior can be achieved using features
available in current Python versions.

The approach has at least the following two technical advantages.
1. It requires no change to Python
2. It provides backwards compatibility all the way back to 3.0.

The spelling is arguably ugly, but this should be weighted against
the, IMHO, extremely rare use of this feature.


>
> If that works at all, I don't think its something we want to guarantee
> will work.


It is guaranteed to work by PEP-3131:
https://www.python.org/dev/peps/pep-3131

"All identifiers are converted into the normal form NFKC while parsing;
comparison of identifiers is based on NFKC."

NFKC normalization means spam must be considered the same identifier as
𝐬𝐩𝐚𝐦 .

Note that the choice for NFKC normalization was apparently explicitly
discussed and decided upon at the time.
Since the difference between NFC and NFKC is exactly that identifiers like
spam and  𝐬𝐩𝐚𝐦 are different
under the former and identical under the latter, I take it this is all
quite intentional.



> And for what it's worth, what I see is eight empty boxes
> (missing glyph symbols).
>
>
I am afraid that mostly shows that your mailer has a bug in handling
non-BMP unicode
characters; you should be seeing FOUR missing glyph symbols.

Stephan


>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180518/95050c12/attachment.html>


More information about the Python-ideas mailing list