Passing parameters using **kargs

Terry Reedy tjreedy at udel.edu
Wed Jun 9 00:23:52 CEST 2004


"Aahz" <aahz at pythoncraft.com> wrote in message
news:ca50ga$hhl$1 at panix1.panix.com...
> >_f_orig = f
> >def f(*largs, **kargs):
> >  print 'f called with' largs, 'and', kargs
> >  f(*largs, **kargs)
>
> You mean
>
>   _f_orig(*largs, **kargs)

Of course.  Silly 'rushing out the door' mistake.

> I prefer this version:
>
> def debugParams(func):
>     def debugger(*args, **kwargs):
>         for arg in args:
>             print type(arg), arg
>         for name in kwargs:
>             value = kwargs[name]
>             print name, type(value), value
>         return func(*args, **kwargs)
>     return debugger
>
> f = debugParams(f)

So do I, for its elaboration, factorization, and closure.  I am saving it.

Terry J. Reedy







More information about the Python-list mailing list