I have some python code that defines a new function based on an old one. It looks like this
def myFunction(a: int, b: int, c: int):
# Do stuff
myNewFunction = lambda a, b: myFunction(a, b, 0)
My new function is the same as the old function, but sets the last argument to 0.
My question: Say I did not know the function took three arguments. Can I make the above solution more generic? An invalid solution with the right intention might be something like:
def myFunction(a: int, b: int, c: int):
# Do stuff
func_args = myFunction.__code__.co_varnames
func_args = func_args[:-1]
myNewFunction = lambda *func_args : myFunction(*func_args, 0)
'co_argvars' in dir(myFunction.__code__)results to False.