A similar question has been asked before but I don't know that I like the answer. You have a parent function, which calls a child function.
def parent(a):
return child(a) * 2
def child(a, b=10, c=20):
return a + b + c
If I want the parent method to expose b and c, I can do something like below. It works, but seems cumbersome, as I'm reaching for it a lot (maybe that suggests some other problem).
def parent(a, b=None, c=None):
kwargs = {}
if b is not None:
kwargs['b']=b
if c is not None:
kwargs['c']=c
return child(a, **kwargs)
Is there a better (i.e. less code) way to do this?
child(a=a, b=b, c=c).parent = childhas the exact same functionality?