I've been trying to understand the algorithm Python follows when assigning values to function parameters and it's just been very confusing. I would like to understand the algorithm better so that I can actually know what values get assigned to what parameters and when. There are positional arguments, keyword arguments, *args, *kwargs, and keyword only arguments. How do these all get assigned and in what order?
Take the following code snippet for one specific example:
def func(a, b, c):
print(a, b, c)
If I call this function in the following format, it is going to run normally:
func(c=3, *(1, 2)) # prints 1 2 3
However if I run it using this it gives a SyntaxError:
func(c=3, 1, 2)
How are the two forms of the call different? In the first call, the tuple gets unpacked into individual arguments. Isn't it the same as being converted into the second form? If that's what happens then the second form should work too, but it doesn't.
So what's actually happening here?