Get actual call signature?

Jarek Zgoda jzgoda at
Tue Mar 18 11:40:34 CET 2008

Say, I have a function defined as:

def fun(arg_one, arg_two='x', arg_three=None):

Is there any way to get actual arguments that will be effectively used
when I call this function in various ways, like:

fun(5) => [5, 'x', None]
fun(5, arg_three=['a', 'b']) => [5, 'x', ['a', 'b']]
fun(5, 'something') => [5, 'something', None]

(et caetera, using all possible mixes of positional, keyword and default

I'd like to wrap function definition with a decorator that intercepts
not only passed arguments, but also defaults that will be actually used
in execution.

If this sounds not feasible (or is simply impossible), I'll happily
throw this idea and look for another one. ;)

Jarek Zgoda
Skype: jzgoda | GTalk: zgoda at | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

More information about the Python-list mailing list