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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • qxyuestc@yahoo.cn

    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

    #2
    Re: what's the difference between f(a) and f(*a)

    On Tue, 02 Sep 2008 06:24:21 -0700, qxyuestc wrote:
    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

    Comment

    • Bruno Desthuilliers

      #3
      Re: what's the difference between f(a) and f(*a)

      qxyuestc@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):


      Comment

      Working...