I have a function that takes in kwargs. I want to use the kwargs parameters by name without having to declare each explicitly as either a parameter or variable. Is there a way to use my_var_key
by passing in kwargs without having to specifically define it in the function call, or is the only way to use kwargs[ "my_var_key" ]
?
E.g. I want something like
def func(**kwargs):
print(my_var_key)
as opposed to
def func(my_var_key, **kwargs):
print(my_var_key)
or
def func(**kwargs):
print(kwargs[ "my_var_key" ])
I'm okay with it breaking if the key doesn't exist.