[Python-ideas] Attribute-Getter Syntax Proposal

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Mar 8 18:53:06 EST 2019

Samuel Li wrote:
> .attribute -> lambda x: x.attribute
> .method(*args, **kwargs) -> lambda x: x.method(*args, **kwargs)

Leading dots can be hard to spot when reading code.

Also, I'm not convinced that use cases for this are frequent enough
to warrant new syntax.

Something akin to this can already be done in simple cases:

    map(string.upper, some_list)

Anything more complicated, such as passing arguments, is probably
better expressed with a comprehension.


More information about the Python-ideas mailing list