passing **kwargs to a function

Abel Daniel abli at freemail.hu
Wed Mar 12 14:22:15 EST 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?

ps. use a real email address or one ending with .invalid
(bobnotbob at byu.edu bounces with 'unknown user')

--
Abel Daniel





More information about the Python-list mailing list