0

Is it possible to have a single function that can be run with two different names and pass a new arg setting as well as all others?

I am thinking something like this:

def func1(a, b=False):
    print(a)
    print(b)

func2 = func1(b=True)

Where this function is being run by other code on the command line and a is a string, lets say I set it to "hello".

Output for func1:

hello
False

Output for func2:

hello
True
alphadmon
  • 396
  • 4
  • 17

1 Answers1

1

Just define another function that calls the first function after setting the b argument to True.

def func2(*args, **kwargs):
    kwargs['b'] = True
    func1(*args, **kwargs)
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Thank you, the problem I have with this way is the actual function in questions has many many args and I am aiming to bypass the need to pass so many args twice and rather by default pass all of them but change one. – alphadmon Sep 28 '22 at 23:31
  • 1
    I've updated it to show how to pass all the other arguments. – Barmar Sep 28 '22 at 23:32