Studied myself into a corner again...
def superfunction(*args, **kwargs, k):
^
SyntaxError: invalid syntax
Whats the rule Im breaking here? It seems that youre not supposed to mix 'regular' variables with * variables, but I cant find anyone to confirm or deny this. I read somewhere (and I cant find in now of course) that some types of arguments have to come first, I believe keyword arguments, which may or may not be part of my issue.
Try this:
def superfunction(k, *args, **kwargs):
The **kwargs
variable keyword parameter must be the last part in the function declaration. Second-to-last, the *args
variable position parameter. (In Python 3.x only, you can also have keyword-only parameters between *args
and **kwargs
.) And in the first places, the positional parameters - that's the correct way to declare function parameters. Take a look at this post for additional details.
For the full reference, see the Function definitions section in Python 3.x or Python 2.x.
Syntax should be like this:
def superfunction(k, *args, **kwargs):
First you give all the positional arguments, then non-keyword arguments, and then keyword arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With