[Python-ideas] Crazy idea: allow keywords as names in certain positions
greg.ewing at canterbury.ac.nz
Sun May 13 21:28:51 EDT 2018
Rob Cliffe via Python-ideas wrote:
> def and(x, y):
> return ...
> # and(1,2) # Oops, SyntaxError. Oh, I know:
> globals()['and'](1,2) # Works!
If the rule I proposed for "import" were extended to "def"
then and(1,2) would work. The usual way of using "and" would
no longer work in that module, but this just goes to show
that redefining "and" is a silly thing to do in the first
Redefining the existing keywords could perhaps be forbidden
if you really want to protect people from shooting themselves
in the kidneys this particular way.
More information about the Python-ideas