On Mar 18, 4:24 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 18, 6:40 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > > > > > Say, I have a function defined as: > > > def fun(arg_one, arg_two='x', arg_three=None): > > pass > > > 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 > > arguments) > > > 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. ;) > > I also needed this for a typecheck module I had written some time ago. > It is feasible, but it's rather hairy. I can dig up the code, polish > it and post it as a recipe (or maybe as a patch to the inspect stdlib > module where it belongs). > > George
Posted at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/551779. For any correction or improvement, please leave a comment. George -- http://mail.python.org/mailman/listinfo/python-list