Hmmm... I disagree with Chris.
I'm definitely -1 on a magic dangling 'foo=' after variable names. And something less than -1 on the even more magic "Lisp symbol that isn't a symbol" ':foo'.
Those are just ugly and mysterious.
However, I don't HATE the "mode switch" use of '*' or '**' in function calls. I've certainly written plenty of code where I use the same variable name in the calling scope as I bind in the call. Moreover, function *definitions* have an an analogous mode switch with an isolated '*'.
I'm only -0 on the mode switch style. Another thing to learn isn't really work the characters saved. But it's not awful.
On Fri, Apr 17, 2020 at 8:52 PM Alex Hall <email@example.com> 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://firstname.lastname@example.org/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):
channel=channel, channelid=channelid, error=error,
sched_tz=sched_tz, schedule=schedule, sched_tweet=sched_tweet,
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:
channel=, channelid=, error=,
sched_tz=, schedule=, sched_tweet=,
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
What's the advantage of a mode switch? This seems perfectly clear to
me without any sort of magical cutoff.
Python-ideas mailing list -- email@example.com
To unsubscribe send an email to firstname.lastname@example.org
Message archived at https://email@example.com/message/3HZIDWQWZA6UTYXYZU6IVJIJTFHW3MSK/
Code of Conduct: http://python.org/psf/codeofconduct/