There is no need to create a merged dict, just to unpack it in function call. Isn't that what you actually want:
spam = {'a':1, 'b':2} eggs = {'c':3, 'd':4} def foo(*args, **kwargs): for key, value in kwargs.items(): print(f'{key} -> {value}') foo(**spam, **eggs)
Output:a -> 1
b -> 2
c -> 3
d -> 4
or to extend it with positional arguments:spam = {'a':1, 'b':2} eggs = {'c':3, 'd':4} def foo(*args, **kwargs): for arg in args: print(arg) for key, value in kwargs.items(): print(f'{key} -> {value}') foo('boo', 'woo', **spam, **eggs)
Output:boo
woo
a -> 1
b -> 2
c -> 3
d -> 4
orspam = {'a':1, 'b':2} eggs = {'c':3, 'd':4} bar = ['boo', 'woo'] def foo(*args, **kwargs): for arg in args: print(arg) for key, value in kwargs.items(): print(f'{key} -> {value}') foo(*bar, **spam, **eggs)
Output:boo
woo
a -> 1
b -> 2
c -> 3
d -> 4
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs