How does python pass default parameters for function encapsulation?

for example, there is a function funcA (arg1, arg2=20)

I define a function called funcA in funcB (arg1, arg2) funcB

I hope that when funcB (arg1, arg2) is called, funcA (arg1, arg2) will be called inside the function to pass the parameters arg1 and arg2 to the function funcA.

when I call funcB (arg1), I want funcA (arg1) to be called inside the function to pass the parameter arg1 and default parameter 20 to the function funcA.

how should the declaration of funcB be written at this time?

Aug.31,2021

when passing (arg1,arg2=arg2) to funcB, calling funcA (arg1,arg2=arg2)
when passing (arg1) to funcB, calling funcA (arg1,arg2=20)


def funcA(arg1,arg2=20):
    pass
    
def funcB(arg1,arg2=None):
    kwargs = {}
    if arg2 is not None:
        kwargs['arg2'] = arg2    
    funcA(arg1,**kwargs)

add to the revised version of the building

Menu