How to get name of function's actual parameters in Python?
问题 For example: def func(a): # how to get the name "x" x = 1 func(x) If I use inspect module I can get the stack frame object: import inspect def func(a): print inspect.stack() out: [ (<frame object at 0x7fb973c7a988>, 'ts.py', 9, 'func', [' stack = inspect.stack()\n'], 0) (<frame object at 0x7fb973d74c20>, 'ts.py', 18, '<module>', ['func(x)\n'], 0) ] or use inspect.currentframe() I can get the current frame. But I can only get the name "a" by inspect the function object. Use inspect.stack I can