[Python-ideas] Syntactic sugar to declare partial functions

Chris Angelico rosuav at gmail.com
Mon Aug 13 01:04:51 EDT 2018


On Mon, Aug 13, 2018 at 2:56 PM, Abe Dillon <abedillon at gmail.com> wrote:
> [Chris Angelico]
>>
>> Also, the signature is most decidedly NOT obvious from context
>
> Who decided this? It's been decided by some committee? When you write a key
> function, you don't know how many arguments are going to be passed?

lst.onselect = anonfunc(print(target_item))

What's target_item? If you can't see the signature and see that it's a
parameter, you should look externally for it. What are the parameters
to an onselect function? Doesn't that seem important enough to see the
signature up front?

It's not just *how many* arguments are being passed. It's what they're
called, too. You cannot interpret the body of a function without
knowing that. Hiding that off to the end would make the language
worse, not better.

Plus, can you name any similar language that does that? Every other
language I can think of has the parameters before the body. While this
isn't a clinching argument by any means (Python has a different
argument order for the ternary if operator, for instance), it's
indicative.

ChrisA


More information about the Python-ideas mailing list