[Python-ideas] Keyword only argument on function call
Anders Hovmöller
boxed at killingar.net
Sat Sep 8 09:34:37 EDT 2018
> A finer grained analysis tool would be helpful. I'm -0 on the idea because I believe it would discourage more expressive names in calling contexts in order to enable the proposed syntax. But I also see a big difference between cases where all keywords match calling names and cases where only a few of them do.
I’ll try to find some time to tune it when I get back to work then.
> I.e. this is probably a small win:
>
> # function (a=a, b=b, c=c, d=d)
> function(*, a, b, c, d)
>
> But this feels like it invites confusion and bugs:
>
> # function (a=my_a, b=b, c=my_c, d=d)
> function(*, a=my_a, b, c=my_c, d)
That example could also be rewritten as
function(a=my_a, c=my_c, *, b, d)
or
function(*, b, c, d, a=my_a, c=my_c)
Both are much nicer imo. Hmmm... maybe my suggestion is actually better if the special case is only after * so the first of those is legal and the rest not. Hadn’t considered that option before now.
> I know these examples use simplified and artificial names, but I think the case is even stronger with more realistic names or expressions.
Stronger in what direction? :P
/ Anders
More information about the Python-ideas
mailing list