problems binding a dictionary

vida00 at gmail.com vida00 at gmail.com
Sat Dec 10 12:24:32 EST 2005


vid... at gmail.com wrote:
> this has to be a very silly thing.
>
> I have a function foo taking a dictionary as parameters. i.e.: def
> foo(**kwargs): pass
> when I call foo(param1='blah',param2='bleh',param3='blih') everything
> is fine.
> but when I do:
> >>> def foo(**kwargs):
> ...     pass
> ...
> >>> d=dict(param1='blah',param2='bleh',param3='blih')
> >>> foo(d)
>
> I get:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: foo() takes exactly 0 arguments (1 given)
>
> Why? how do I pass the dictionary *d* to foo()?
> Thanks,
> 
> - Josh.

I mean, short of defining as foo(*args), or foo(dict).




More information about the Python-list mailing list