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

Steven D'Aprano steve at pearwood.info
Fri May 18 09:37:51 EDT 2018

On Fri, May 18, 2018 at 03:09:57PM +0200, Stephan Houben wrote:
> 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;

Earlier you described this suggestion as "a silly joke".


I think you were right then.

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

Aside from the fact that font, editor and keyboard support for such 
non-BMP Unicode characters is very spotty, it isn't the intended 

As you point out, the intended behaviour is that obj.𝐢𝐟 and 
obj.if ought to be identical. Since the later is a syntax error, so 
should be the former.

> 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
> 𝐬𝐩𝐚𝐦 .

It's not the NFKC normalization that I'm questioning. Its the fact that 
it is done too late to catch the use of a keyword.


More information about the Python-ideas mailing list