Possible Duplicate:
How can I programmatically change the argspec of a function in a python decorator?
argspec is a great way to get arguments of a function, but it doesn't work when the function has been decorated:
def dec(func):
@wraps(func)
def wrapper(*a, **k)
return func()
return wrapper
@dec
def f(arg1, arg2, arg3=SOME_VALUE):
return
import inspect
print inspect.argspec(f)
-----------
ArgSpec(args=[], varargs='a', keywords='k', defaults=None)
Argspec should return arg1
, arg2
, arg3
. I think I need to define wrapper
differently as to not use *a
and **k
, but I don't know how.