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
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to