Is there a way to implement a function that has variable number of arguments (*args) and also non-optional keyword arguments? I want to implement something like this:
def foo(positional arguments, keyword arguments,*args):
{
...
}
However, now there seems to be no way to call this function correctly. Let arg1 and arg2 be the arguments of type (*arg) that we want to pass in a function call.
foo(posargs, kwarg=value, arg1, arg2)
is not allowed (kwargs have to be at last), while:
foo(posargs,arg1,arg2,kwarg=value)
would lead to a wrong function call, as then arg1 is positionally assigned to kwarg, inspite of kwarg being supplied a keyword value in the function call.
Is there any alternate defining or calling syntax that avoids this situation, (apart from the trivial solution of calling with kwarg values fed as positional arguments in the function call)?