passing **kwargs to a function

Erik Max Francis max at
Wed Mar 12 04:46:31 CET 2003

Bob Roberts wrote:

> def a(*args, **kwargs):
>     print args,kwargs
>     b(kwargs)
> 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?

Inside a, kwargs is just a local variable that happens to be a
dictionary.  So when you call b(kwargs), you're just calling b with a
dictionary object as the first argument.  What you meant was:


 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Who, my friend, can scale Heaven?
\__/ _The Epic of Gilgamesh_
    EmPy /
 A templating system for Python.

More information about the Python-list mailing list