I want kwargs to have the same exact contents in method2 as whatever gets passed into method1. In this case “foo” is passed into method1 but I want to pass in any arbitrary values and see them in kwargs in both method1 and method2. Is there something I need to do differently with how I call method2?
def method1(*args,**kwargs):
if "foo" in kwargs:
print("method1 has foo in kwargs")
# I need to do something different here
method2(kwargs=kwargs)
def method2(*args,**kwargs):
if "foo" in kwargs:
# I want this to be true
print("method2 has foo in kwargs")
method1(foo=10)
Output:
method1 has foo in kwargs
Desired output:
method1 has foo in kwargs
method2 has foo in kwargs
Let me know if I need to clarify what I’m asking, or if this is not possible.
Keyword expansion.