I have a list...

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Jul 1 04:27:30 EDT 2003


"Damir Hakimov" <agg at astranet.ru> wrote in 
news:20030701113915.226ae9bd.agg at astranet.ru:

> Hi, All!
> 
> say, i have a function:
> 
> def f(*b):
>   print b
>   return
> 
> then i do:
> f(3,4,5)
> (3, 4, 5)
> 
> but i have list f=(3,4,5)
> f(l)
> ((3, 4, 5),)    
> 
> how can i call f function to result
> f(???(b))
> (3, 4, 5)
> 
I'm not sure any of the other responses actually answered the question, 
which I think was meant to be, given a tuple l=3,4,5 how do you pass that 
tuple to the function f so that b simply gets the tuple. The answer is that 
you try:

   >>> f(*l)
   (3,4,5)

If that doesn't work, then you upgrade to a more recent version of Python. 
If you (or your users) really can't upgrade you should use 'apply'.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list