what's the difference between f(a) and f(*a)

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Sep 2 10:06:48 EDT 2008


qxyuestc at yahoo.cn a écrit :
> def sum1(*a): return(sum(i*i for i in a))
> def sum2(a): return(sum(i*i for i in a))
> 
> a=[1,2,3]
> print(sum1(*a), sum2(a))
> ####################################
> showed above: the result from sum1() and sum2() is the same. So, what
> is the difference between f(a) and f(*a)

try this:

sum1(a)
sum2(*a)

Then re-read the FineManual(tm):
http://docs.python.org/tut/node6.html#SECTION006730000000000000000




More information about the Python-list mailing list