Passing variable number of named arguments

Carsten Haese carsten at uniqsys.com
Wed Dec 27 13:53:38 EST 2006


On Wed, 2006-12-27 at 10:37 -0800, Ramashish Baranwal wrote:
>[...]
> def fun2(**kwargs):
>     # get id param
>     id = kwargs.pop('id', '')
>     # pass on remaining to fun1
>     fun1(kwargs)
> 
> When I try to call fun2 I get the following error-
> 
> TypeError: fun1() takes exactly 0 arguments (1 given)
> 
> It seems that the arguments are not passed to fun1 as named arguments.

You have to call fun1 like this: fun1(**kwargs).

-Carsten





More information about the Python-list mailing list