[dgplug-users] Need Help in understanding the Error Message

Ravindra Lakal ravindra.lakal at gmail.com
Tue Feb 28 03:39:45 PST 2017


This link will help you understand the concept of keyword arguments
http://pymbook.readthedocs.io/en/latest/functions.html#keyword-arguments

On Feb 27, 2017 3:07 PM, "Pabitra Pati" <pabitrakumarpati at gmail.com> wrote:

> Hi All,
>
> I want to understand the error message I am getting.
> Below is my code piece :-
>
>     def total(name, *args):
>         if args:
>             print("%s has total money of Rs %d/- " %(name, sum(args)))
>         else:
>             print("%s's piggy bank  has no money" %name)
>
> I can call this method passing the extra arguments inside *().
> I know the correct way of passing the arguments. But, I am passing value
> for 'name' in form of param=value, *intentionally*, so that it throws me
> error. However, I am unable to understand the below error message :-
>
>     >>> total(name="Adi", *(1, 2, 10) )
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in <module>
>     TypeError: total() got multiple values for keyword argument 'name'
>
> How Python is evaluating the above call, that it's getting multiple values
> for the parameter 'name'?
>
> Any help is appreciated.
>
>
> *Thanks,*
>
> *Pabitra*
> _______________________________________________
> Users mailing list
> Users at lists.dgplug.org
> http://lists.dgplug.org/listinfo.cgi/users-dgplug.org
>


More information about the Users mailing list