Is it possible to use a default variable based on previously passed positional arguments?
I'm trying to do something similar:
def ex(a, b=a+1):
return a+b
Is it possible to use a default variable based on previously passed positional arguments?
I'm trying to do something similar:
def ex(a, b=a+1):
return a+b
You can do that inside of the body, but not the signature.
def ex(a, b=None):
if b is None:
b=a+1
return a+b