Passing a tuple to a function as multiple arguments

Ben Warren bwarren at qstreams.com
Thu Sep 6 23:02:12 EDT 2007


Hello,

Let's say I have a function with a variable number of arguments (please ignore syntax errors):

def myfunc(a,b,c,d,...):

and I have a tuple whose contents I want to pass to the function.  The number of elements in the tuple will not always be the same.

T = A,B,C,D,...

Is there a way that I can pass the contents of the tuple to the function without explicitly indexing the elements?  Something like:

myfunc(magic(T))

where magic() expands the tuple to its multiple elements.  I've tried various for loop constructs, but everything I can think of returns a list, which doesn't work because it's viewed as one parameter.


thanks,
Ben  






More information about the Python-list mailing list