[Python-ideas] Attribute-Getter Syntax Proposal

Jonathan Fine jfine2358 at gmail.com
Fri Mar 8 13:07:21 EST 2019

Hi Samuel

Interesting idea, and certainly addresses a real problem, if you find
yourself creating lots of lambda expressions. But in my first opinion,
not so useful that it merits adding to the syntax of Python.

(Even if I never use it, it puts an extra burden on me when scanning
Python code. Something that used to look like a syntax error is now
valid. That's more work for me.)

However, you can already achieve something similar, and perhaps more
expressive. It is possible to define an object 'magic' such that
   fn = magic.upper
   fn = lambda x: x.upper()
are effectively equivalent.

And this can be done now. No need for a PEP and a new version of
Python. And available for those who have to use some fixed already
existing Python versions.

I hope you'd be interesting in coding this up yourself. I'd have a
limited amount of time to help you, but it would put you on a good
learning curve, for fundamentals of the Python object model.


More information about the Python-ideas mailing list