Passing parameters using **kargs
Terry Reedy
tjreedy at udel.edu
Tue Jun 8 08:41:52 EDT 2004
"Duncan Booth"
> Thomas Philips) >
> > I want to access parameters that are passed into a function using the
> > **kargs idiom. I define f(**kargs) via
> >
> > def f(**kargs):
> > print kargs
> The ** argument is for keyword arguments where you don't know in advance
> all the keywords that might be valid.
Or if you don't care, or want to intercept invalid calls. Interestingly,
the OP's example is the beginning of a possible debug wrapper usage where
one either does not have a function's code or does not want to modify it
directly. Possible example:
_f_orig = f
def f(*largs, **kargs):
print 'f called with' largs, 'and', kargs
f(*largs, **kargs)
Terry J. Reedy
More information about the Python-list
mailing list