Note that Javascript does something similar,
in that reserved keywords are allowed in member access.

var x = {if : 42};
console.log(x.if);

Stephan


2018-05-13 20:42 GMT+02:00 Eric Fahlgren <ericfahlgren@gmail.com>:
On Sun, May 13, 2018 at 11:20 AM Guido van Rossum <guido@python.org> wrote:
For example, we could allow keywords after 'def' and after a period, and then the following would become legal:

​Our modeling database overloads getattr/setattr (think SQLAlchemy) to allow us to access to database fields as if they were Python data members.  Nothing new here, but we do have problems with keyword collisions on some of the objects, as we are wrapping an already-existing modeling language (MSC Adams Solver dataset) with our objects.  We were pleased with 'print' became a function, because it removed the restriction from that one, but one of the remaining ones is 'return', like this:

class Sensor:
    def __init__(self):
        setattr(self, "print", 0)
        setattr(self, "return", 0)

s = Sensor()
s.print  # Works now, didn't in Python 2.
s.return  # Bork.

I have a decades old +1 on this.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/