R
Ramashish Baranwal
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
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