On Fri, Apr 17, 2020 at 8:52 PM Alex Hall <[email protected]> wrote:
>>
>> But this means the reader could miss the star, especially with a very large
>> function call over multiple lines, and if that reader happens to use that
>> particular function A LOT and know the parameter order without having to
>> look they would pretty easily believe the arguments are doing something
>> different than what is actually happening.
>
>
> Thank you for giving an actual scenario explaining how confusion could occur.
> Personally I think it's a very unlikely edge case (particularly someone
> comparing argument order to their memory), and someone falsely thinking that
> correct code is buggy is not a major problem anyway.
>
> I propose using two asterisks instead of one as the magical argument
> separator. `**` is more closely associated with keyword arguments, it's
> harder to visually miss, and it avoids the problem mentioned
> [here](https://mail.python.org/archives/list/[email protected]/message/XFZ5VH5DKIFJ423FKCTHXPHDONAO3DFI/)
> which I think was a valid point. So a call would look like:
>
> function(**, dunder, invert, private, meta, ignorecase)
>
All of these mode-switch proposals have the fundamental problem that
you then cannot mix shorthand and longhand forms - once you go
shorthand, suddenly everything has to be shorthand. I don't like that.
The original proposal was entirely self-contained and has a very
simple interpretation. Consider this example of actual production code
(same one as I posted earlier):
return render_template("index.html",
twitter=twitter, username=user["display_name"],
channel=channel, channelid=channelid, error=error,
setups=database.list_setups(channelid),
sched_tz=sched_tz, schedule=schedule, sched_tweet=sched_tweet,
checklist=database.get_checklist(channelid),
timers=database.list_timers(channelid),
tweets=tweets,
)
Aside from the first parameter, everything is keyword args, and there
is no particular order to them. The render_template function doesn't
define a set of parameters - it takes whatever it's given and passes
it along to the template itself. If I could use the "name=" shorthand,
I could write this thus:
return render_template("index.html",
twitter=, username=user["display_name"],
channel=, channelid=, error=,
setups=database.list_setups(channelid),
sched_tz=, schedule=, sched_tweet=,
checklist=database.get_checklist(channelid),
timers=database.list_timers(channelid),
tweets=,
)
Each individual entry can use the shorthand, and it has a well-defined
meaning. The order doesn't define which ones can and can't use
shorthand.
What's the advantage of a mode switch? This seems perfectly clear to
me without any sort of magical cutoff.
ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/3HZIDWQWZA6UTYXYZU6IVJIJTFHW3MSK/
Code of Conduct: http://python.org/psf/codeofconduct/