unwrapping argument tuples

Carsten Geckeler nospam at no.spam
Wed Dec 13 19:52:23 EST 2000


On 13 Dec 2000, Prashanth Mundkur wrote:

> is there a way to unwrap a tuple argument to a function and
> match it to the parameters?
> 
> that is, if
> 
> >>>lst = [1, 2, 3]
> 
> >>>def func (p1,p2,p3):
>        return p1+p2+p3
> 
> then I want to apply func somewhat as
> 
> >>>func(lst)
> 6
> 
> such that the elements of lst are unwrapped and and matched to p1, p2,
> p3
> 
> tx for any tips.
> 
> --prashanth

Well, just try:

>>> apply(func, lst)
6

Cheers, Carsten
-- 
Carsten Geckeler:  carsten dot geckeler at gmx dot de
To get proper email-address replace `dot' and `at' by the corresponding symbols.





More information about the Python-list mailing list