passing **kwargs to a function

Abel Daniel abli at freemail.hu
Wed Mar 12 20:00:44 CET 2003


Bob Roberts (bobnotbob at byu.edu) wrote:
> Observe the folling code:
> def a(*args, **kwargs):
>     print args,kwargs
>     b(kwargs)
      b(**kwargs)
is what you want here
> 
> def b(*args, **kwargs):
>     print args,kwargs
> 
> a(a=1,b=2
> 
> And it's output:
> 
> () {'a': 1, 'b': 2}
> ({'a': 1, 'b': 2},) {}
> 
> I am trying to pass int b() the exact same keyword arguments that were
> passed into it.  As you can see, it does't arrive in ths same way.  I
> want the kwargs variable inside a() and b() to be exactly the same. 
> How do I do that?


--
Abel Daniel





More information about the Python-list mailing list