argument matching question

Learning Python learningProgramming at gmail.com
Thu Aug 25 21:03:09 EDT 2005


I know this is dummy, just never saw an example of this.


I want to use the special argument matching.

A code like this:

def adder(**varargs):
      sum=varargs[varargs.keys()[0]]
      for next in varargs.keys()[1:]:
                sum=sum+varargs[next]
      return sum

print adder( "first","second",'third')


------------------------
It pop up error like this:

Traceback (most recent call last):
  File "learn.py", line 7, in ?
    print adder( "first","second",'third')
TypeError: adder() takes exactly 0 arguments (3 given)


How to pass arguments to a functions that use dictionary collection?


Thanks




More information about the Python-list mailing list