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

Steven D'Aprano steve at pearwood.info
Thu May 17 21:34:26 EDT 2018


On Thu, May 17, 2018 at 11:41:33AM -0700, Neil Girdhar wrote:
> My preference is to do nothing.  If you end up making "where" a keyword in 
> Python 3.8, numpy will probably:

This is only incidently about "where". I'm hoping that the "where" (or 
"given") proposal is rejected. It is so verbose and redundantly 
repetitious in the common case that rather than being an improvement 
over the status quo, it is worse. But that's by-the-by.


> * rename their where function to "where_" in 3.8
> * add a where_ alias in Python < 3.8.
> 
> And then people will have to fix their code in 3.8 anyway.  Only instead of 
> learning a new verbatim syntax, they will just add the familiar underscore.

You should be thinking forward two or three versions from now, when 
\name is the familiar syntax and name_ looks like you started to write 
an identifier using the underscore_words_convention but got distracted 
halfway through.

Remember that (if approved) verbatim names will not be "that new syntax" 
for long. We don't still talk about "that new fangled list comprehension 
syntax" or "that new yield keyword". That was the problem with the "old 
versus new style classes" terminology: at the point that "new-style 
classes" had been around for six releases, approaching a decade, they 
weren't new any more.


> One thing that should ideally be done is to improve the SyntaxError 
> processing to special case use of keywords in places that identifiers are 
> used. 

This is worth doing regardless of whether or not we get verbatim strings 
or some other alternative. You ought to raise it on the bug tracker.



-- 
Steve


More information about the Python-ideas mailing list