Is it possible for a python function to ignore unused kwargs

keyword-argument, python

Solution

Sure. Just add `**kwargs` to the function signature:

def add(a, b, c, **kwargs):
    return a + b + c

kwargs = dict(a=1, b=2, c=3, d=4)
print add(**kwargs) 
#prints 6

Problem

If I have a simple function: ``` def add(a, b, c): return a + b + c ``` Is it possible for me to make it so that if I supply an unused kwarg, it is simply ignored? ``` kwargs = dict(a=1, b=2, c=3, d=4) print add(**kwargs) #prints 6 ```

Original source

Related problems