Python has a very interesting way of dealing with function arguments (that I personally really like).
If we define a new function
def myFunc(*args, **kwargs):
print(args, kwargs)
I can call the function with
myFunc(1, 2, 3, 4, a = 'a', b = 'b')
and get the output of
([1, 2, 3, 4], {'a': 'a', 'b': 'b'})
To specifcally answer your question, I can also call the function like this
myFunc(*[1, 2, 3, 4], **{'a': 'a', 'b': 'b'})
and get the exact same output
I can also use the asterisk to pass through positional arguments
def add(x, y):
return x + y
and call it with
nums = [1, 2]
print(add(*nums))
stdout: 3
As you can see, the 1 and 2 are distributed amongst the function parameters.
TDLR
* unpacks a list into arguments, and ** unpacks a dictionary into keyword arguments
*
and **
is the equivalent to ...
in some other languages, if you want reference to that too.