I am writing some code that receives functions with variable numbers of arguments. I also have lists of those arguments (but the functions expect separate arguments, not one list). Is there a way to convert this list into arguments of a form that the functions might like (and sadly, they cannot just be converted to strings)?
1 Answer
Yes, just prefix the list with a * to unpack it:
args = [1, 2, 3]
foo(*args) # equivalent to foo(1, 2, 3)
More details available at the Python tutorial.