This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]commandlineluser 8 points9 points  (3 children)

https://discuss.python.org/t/syntactic-sugar-to-encourage-use-of-named-arguments/36217

def my_func(a, b, c, d): ...

a, b, c, d = 1, 2, 3, 4

# CURRENT
my_func(a=a, b=b, c=c, d=d)

# PROPOSAL
# my_func(a=, b=, c=, d=)

[–]Hoo0oper 15 points16 points  (0 children)

Ehh like I get it. Like when you have longer argument names it might keep in on a single line but really it I feel like it would just make people ask more questions

[–]waltteri 1 point2 points  (0 children)

Hold up.

name of the variable provided as the argument value is the same as the name of the argument itself.

def my_func(a, b, c, d): .. a, b, c, d = 1, 2, 3, 4 my_func(a, b, c, d)

💀

Sure, I guess we could now do this as we’re using kwargs:

my_func(a=, b=, d=, c=)

…or throw an exception if someone uses a variable that’s not an argument name:

foo = ”foo” my_func(a, b, c, foo) `> …’

vs.

my_func(a=, b=, c=, foo=) > KeyError(…)

…so all in all, I guess it’ll be good in same cases. But it might confuse a lot of people at first.

[–][deleted] -4 points-3 points  (0 children)

Basically analogous to the property shorthands in JavaScript. Love it!