Re: Passing variable number of named arguments
Carsten Haese wrote: > 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). Wow. thanks Carsten.. -Ram -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing variable number of named arguments
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 -- http://mail.python.org/mailman/listinfo/python-list
Passing variable number of named arguments
Hi, I need to process few out of a variable number of named arguments in a function and pass the remaining to another function that also takes variable number of named arguments. Consider this simple example, def fun1(**kwargs): print kwargs.keys() 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. How can I go about this? Using a dictionary in place of kwargs would be a way, but I can't modify fun1, so thats ruled out for me. Thanks, Ram -- http://mail.python.org/mailman/listinfo/python-list