A lone * forces the rest of the arguments to be keyword-only arguments, meaning they must be specified as a keyword arguments.
The lone
*beforexandymeans that they must be specified as keyword arguments.So, if we were to try to call multiply with two positional arguments, we’ll get an error:
To call this function, we have to explicitly specify
xandyas keyword arguments:If we call this function with nothing you’ll see an error message similar to what we saw before about required keyword-only arguments:
So, whenever you see a function that uses
*to capture any number of positional arguments (e.g.*argsin the function definition), note that any arguments defined after that*capturing can only be specified as a keyword argument (they’re keyword-only arguments).Additionally, if you come across a function with a lone
*followed by a comma, that means that every argument after that point is a keyword-only argument (it must be specified by its name when that function is called).