[Python-ideas] Crazy idea: allow keywords as names in certain positions

Rob Cliffe rob.cliffe at btinternet.com
Sun May 13 22:38:21 EDT 2018



On 14/05/2018 02:28, Greg Ewing wrote:
> 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
> place.
>
> Redefining the existing keywords could perhaps be forbidden
> if you really want to protect people from shooting themselves
> in the kidneys this particular way.
>
If you forbid redefining keywords, you remove the whole point of this 
proposal: to allow keywords to be sometimes used as bona fide keywords, 
sometimes as identifiers.

I really do not intend to give offence (I know that that's 
counter-productive).  But I have formed a very strong opinion - which of 
course may be wrong, and certainly won't be universally shared - and I 
am honestly expressing that opinion: Nothing I have seen in this thread 
so far has persuaded me that this proposal has any merit.



More information about the Python-ideas mailing list