getargs = lambda func: (func.func_code.co_varnames[:func.func_code.co_argcount])
Example Session
#Example Session
getargs = lambda func: (func.func_code.co_varnames[:func.func_code.co_argcount])
def addition(x,y):
return x+y
print getargs(addition)
#('x', 'y')
Yep, it’s really that simple. No weird exec functions needed, no intrusive introspection via the disassembler.