Is the "pack" argument possible in Python? In the library, I have the following functions, that I can not change (simplified):
def g (a, b = 2): print a, b df f (rgr): g ) I can
o = {'a': 10, 'b': 20} g (** o) 10 20 < / Code> But how can I / I pass it through the f ?
That is what I do not want:
f (** o) traceback (last call last): File "& lt; stdin & gt;" , Line 1, & lt; Module & gt; TypeError: f () is an unexpected keyword argument 'a' f (o) {'a': 10, 'b': 20} 2
f is to accept arbitrary (static and) keyword arguments:
def f (* args, * * Kwargs: g (* args, ** kwargs) If you do not want to accept the static logic on f , then Leave * Args part
Comments
Post a Comment