Syntactic sugar to encourage use of named arguments

As an alternative to the proposed syntax, what about the option of having the call be the same as the signature:


def foo(x,y, /, z, *, a, b):
    ...

# Current usage
a = 4
b = 5    

foo(1,2,3,a=4,b=5)

# Pass as a dictionary
kwargs = {
    'z': 3,
    'a': a,
    'b': b
}

foo(1,2, **kwargs)


# With new shorthand

foo(1,2, z=3, *, a, b)
foo(1,2, *, b, a) # Order doesn't matter
8 Likes