I'm pretty new to Python and have written a function that has 5 arguments:
def function(a,b,c,d=False,e=" "):
Argument d can either be true or false. If false, then the default value for e will be white space, and we wouldn't need to pass this into the function when calling it, if true, then we can either pass an argument to e, or leave it blank.
function(a,b,c,False) #Example 1: d==False
function(a,b,c,True,'*') #Example 2: d==True, then pass value to e to override default
My issue, however, lies with the following example:
function(a,b,c,True) #Example 3: d==True but no value passed to e
If d is true and no value is passed to argument e, I want to change the default value of e to something else. I only want to do this in instances where d==True and e isn't passed. Basically, I want the default behaviour of argument e to be dependent on the boolean value of d:
def function(a,b,c,d=False,e=" " if d==False, '*' if d=True)
Basically, I want two default states for argument e, dependent on whether argument d is True or False.
Is this possible?