14 May
2018
14 May
'18
1:28 a.m.
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. -- Greg