thx. That works. After a a bit of head scratching seems I've got a wrong idea on how python handles function args.
def times(x,y):
return y*x
def apply_func(f,x):
return f(x)
print (apply_func(times,(2,3)))
expected outcome : 6
actual outcome : error, don't like tuple as args for function times
Function parameter ( arg ) lists are written with the syntax of tuples, but they are not tuples. Attempt to pass a tuple as an arg list results in an error. So if the tuple (2,3) is not appropriate here... what is?
my trick to bypass python's arg list ettiquette : always pack arg lists into a tuple. then have your functions take one parameter. 1st line of function is to unpack the tuple
e.g.
def my_funct(my_args):
x,y,z = my_args
# function code here
ahahaha, i beat the system
def times(z):
(x,y)=z
return y*x
def apply_func(f,x):
return f(x)
print (apply_func(times,(2,3)))
works here