Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Python

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

 
Jump to:  
 
Guest
PostPosted: Tue Sep 02, 2008 1:24 pm    Post subject: what's the difference between f(a) and f(*a)
       
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)
 

 
Marc 'BlackJack' Rintsch
PostPosted: Tue Sep 02, 2008 1:24 pm    Post subject: Re: what's the difference between f(a) and f(*a)
       
On Tue, 02 Sep 2008 06:24:21 -0700, qxyuestc wrote:

Quote:
showed above: the result from sum1() and sum2() is the same. So, what is
the difference between f(a) and f(*a)

f(a) -> f([1, 2, 3])
f(*a) -> f(1, 2, 3)

Ciao,
Marc 'BlackJack' Rintsch
 

 
Bruno Desthuilliers
PostPosted: Tue Sep 02, 2008 1:24 pm    Post subject: Re: what's the difference between f(a) and f(*a)
       
qxyuestc@yahoo.cn a écrit :
Quote:
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):
LINK
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

programy dla firmy karty plastikowe darowizna Internetowy sennik okna