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

Greg Ewing greg.ewing at canterbury.ac.nz
Wed May 16 18:58:34 EDT 2018


Todd wrote:
> The overall issue is that python has no way of knowing 
> if the keyword is being used for legitimate backwards-compatibility 
> purposes or someone intentionally overrode after it was made a keyword 
> because they somehow thought it was a good idea.  That is why being 
> explicit about overriding the keyword is so important.

The trouble with explicitly overriding keywords is that it
still requires old code to be changed whenever a new keyword
is added, which as far as I can see almost competely defeats
the purpose. If e.g. you need to change all uses of given
to \given in order for your code to keep working in
Python 3.x for some x, you might just as well change it
to given_ or some other already-legal name.

The only remotely legitimate use I can think of is for
calling APIs that come from a different language, but the
same thing applies there -- names in the Python binding can
always be modified somehow to make them legal.

As far as I can see, any mechanism allowing keywords to be
used as names has to be completely transparent to existing
code, otherwise there's no point in it.

-- 
Greg


More information about the Python-ideas mailing list