<s>[INST] Getting method parameter names in python Given the python function:
def aMethod(arg1, arg2):
    pass

How can I extract the number and names of the arguments. Ie. given that I have a reference to func, I want the func.[something] to return ("arg1", "arg2")
The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that they appear for the actual function as a key. Ie. how would the decorator look that printed "a,b" when I call aMethod("a","b")
 [/INST] Take a look at the inspect module - this will do the inspection of the various code object properties for you.
>>> inspect.getargspec(aMethod)
(['arg1', 'arg2'], None, None, None)

The other results are the name of the *args and **kwargs variables, and the defaults provided.  ie.
>>> def foo(a,b,c=4, *arglist, **keywords): pass
>>> inspect.getargspec(foo)
(['a', 'b', 'c'], 'arglist', 'keywords', (4,))

 </s>