I have a outer function foo
that calls two inner functions, bar1
and bar2
. Each inner function (bar) has default parameters. I'd like to be able to call foo and specify whichever parameters I want, and then use the inner function defaults for whichever parameters I don't specify. How do I do this?
Example:
def foo(**kwargs):
print(bar1(kwargs['b1p1'], kwargs['b1p2'])
+ bar2(kwargs['b2p1'], kwargs['b2p2']))
def bar1(b1p1 = '', b1p2 = ''):
return str(b1p1+b1p2)
def bar2(b2p1 = 0, b2p2 = 0):
return str(b2p1 * b2p2)
foo(b1p1 = 'a', b1p2='b', b2p1 = 1, b2p2 = 3) #returns ab3
foo(b1p1 = 'a') #should return a0
foo() #should return 0