def myF(a, b):
return a*b-2*b
Let's say that I want a default value for b to be a-1:
def myF(a, b=a-1):
return a*b-2*b
gets the error message:
NameError: name 'a' is not defined
I can use the code below:
def myF(a, b):
return a*b-2*b
def myDefaultF(a):
return myF(a, a-1)
to have myF with default value, but I don't like it.
How can I avoid myDefaultF and have myF with default value a-1 for b without errors?