bradtgmurray bradtgmurray - 5 months ago 42
Python Question

Find names of positional arguments through introspection

Is there a way to figure out the names of the positional arguments to a python function?

def foo(arg1, arg2):

# How do I find out want the 1st argument to f is called? I want 'arg1' as an answer


The function inspect.getargspec() does what you need in Python 2.

In Python 3, this has been deprecated, and you should instead use signature.