[Python-ideas] Crazy idea: allow keywords as names in certain positions
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun May 13 21:07:49 EDT 2018
Elias Tarhini wrote:
> The thought of writing "operator.not" is appealing, but
> being forced to use *that* (with *from operator import not* being
> non-allowable) may not be.
Under the proposal I made in my last post, "from operator import not"
would be fine -- you just wouldn't be able to use the "not" operator
anywhere in the module then. :-)
A more nuanced version would have the effect restricted to the
scope the import appears in, so that you could write
def f():
from operator import not
# 'not' is now an ordinary name inside this
# function, but it's business as usual elsewhere
Someone else can figure out how to make the parser handle
this, though. :-)
--
Greg
More information about the Python-ideas
mailing list