Say I've got this function (a very simple function just to get my point across):
def f(x):
if x:
return(True)
return(False)
Now I want to use this function as an optional argument in another function, e.g. I tried something like this:
def g(x, f_out = f(x)):
return(f_out)
So basically if I did g(1) the output should be True, and if I did g(0) I want the output to be False, as f(0) is False and thus f_out is False.
When I try this though, f_out is always True regardless of x. How can I make it such that the function f is actually called when getting the value f_out?
The code that I'm actually using this principle on is obviously more complicated but it's the same idea; I have an optional argument in some function1 that calls a different function2 with parameters which are already parameters in function1, e.g. x in my example. (Sorry I'm aware that's perhaps an unclear way of explaining.)