Calmcode - args kwargs: error

Why does the order of parameters cause errors in python?

1 2 3 4 5 6 7

The order in which you place the arguments is important. Do it wrong and you'll get an error.

Let's have a look at the same function.

def function(a, b, *args, keyword=True, **kwargs):
    print(a, b)
    print(args)
    print(keyword)
    print(kwargs)

Note that this call will fail.

function(a=1, b=2, 5, 3, 4, param=42)

But this one will not.

function(1, 2, 5, 3, 4, param=42)

If you use the rule in the video you may remember why.