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

Eric Fahlgren ericfahlgren at gmail.com
Sun May 13 14:42:28 EDT 2018

On Sun, May 13, 2018 at 11:20 AM Guido van Rossum <guido at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180513/b1928cde/attachment.html>

More information about the Python-ideas mailing list