bradtgmurray bradtgmurray - 1 year ago 77
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

Answer Source

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download