Forwarding keyword arguments from one function to another
Tim Wintle
tim.wintle at teamrubber.com
Sun Feb 22 14:52:13 EST 2009
More information about the Python-list mailing list
Sun Feb 22 14:52:13 EST 2009
- Previous message (by thread): Forwarding keyword arguments from one function to another
- Next message (by thread): Forwarding keyword arguments from one function to another
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 2009-02-22 at 11:44 -0800, Ravi wrote:
> The following code didn't work:
>
<snip>
> def g(self, s, kwds):
> print s
> print kwds
This expects the function g to be called with the parameters "s" and
"kwds"
<snip>
> def g(self, s, **kwds):
> print s
> print kwds
This expects to be passed the parameter "s", and various keyword
arguments, which will be put into the dict "kwds".
when you call
o.g("string",**kwds)
you are passing the parameter "string" as the first parameter, and then
a sequence of keyword arguments taken from kwds, which will be passed
separately.
This is what the second form expects, but not what the first one
expects.
Tim Wintle
- Previous message (by thread): Forwarding keyword arguments from one function to another
- Next message (by thread): Forwarding keyword arguments from one function to another
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list