I was wondering if there is a way to take the elements in a list and insert them into the inputs of a function. So for example
def function(x,y,z):
#does stuff
def main():
changing_list=[8,9,10]
function(changing_list)
I am using the function GetRows
in Spotfire
, which allows different amounts of input to be used. So I am planning to put the names of rows I am going to use into the list and then use it to give the inputs into the function. If there is a better way of doing this please tell me, I can't put in the inputs before hand due to me not knowing which rows I will be using beforehand. If there is something unclear please ask me to clarify. An important point that I noticed that I may have left out after looking at the answers. I cannot adjust the code in the function due to me not have access to it. Also the function might not always accept 3 inputs, it will vary depending on the what happens when the code runs before hand, the list may have 5 elements in one run and 1 element in the next one.
Change the line of:
function(changing_list)
To:
function(*changing_list)
If you're in Python 3.
Use:
function(l[0], l[1], l[2])