Implicit Keyword Arguments for Python
lwn.net
lwn.net
But like the walrus operator (I was on the side of reuse of the keyword as), I worry I'll be on the losing side of this one too.
def foo(long_argument1: str, long_argument2: str):
pass
long_argument1 = “some value”
long_argument2 = “another value”
foo(**{long_argument1, long_argument2})*https://rust-lang.github.io/rfcs/1682-field-init-shorthand.h...
Cause you know, "explicit is better than implicit"
A small addition: I think it will lend itself to callers preferring to the use the same names in the calling function as in the parameters to take advantage of this feature, instead of using a name that is more appropriate for the context.
I wonder how scoping would work. That could result in the interesting bugs.
How do people who code in languages that have this feature like it?
The more concrete a function is, it's more useful than not to have the names match (or be very similar); and that mismatched names smell of bad naming.
Comparing "customerName = customer.bankId" with "customerName = customer.name".. there's less cognitive overhead if the latter is the one which works.
For very 'concrete' functions, e.g. `updateInfo(bankId, customerName, payload)` or `updateInfo(customerName, bankId, payload)` both look correct, and it's possible to imagine one being a typo of another. Named arguments avoids this.
:o) And for those who use LLM tools which can quickly output lots of code which looks-correct-but-may-be-buggy, it's nice to have these 'conservative' features which reduce risk of 'looks correct, but is not what was intended'.
Whereas, say, the arguments to string.format or list.map, these functions are so abstract that positional arguments don't suffer the same risks (to the same extent).
a = 1
b = "foo"
c = null
f({a, b, c})
This is a popular feature.Another major miss-step in recent python syntax evolution, even worse than the worst perl5 obscurities.
For sure everybody will read that the name will be empty, and not not the value of the variable with the same name.
func2(=visibility, =frobnification_level) looks much better
># this could be used: func2(=visibility, =frobnification_level
Please, no. It takes two seconds to write it out, this will lead to hard to read code.
I’m curious to hear why you think this. What is it about duplicating the variable name that you feel makes the code clearer?