Skip to content

Instantly share code, notes, and snippets.

@stinoga
Created October 1, 2015 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stinoga/86351c5368e3e45c2546 to your computer and use it in GitHub Desktop.
Save stinoga/86351c5368e3e45c2546 to your computer and use it in GitHub Desktop.
List Arguments in Python
import inspect
def func(a, b, c):
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
print 'function name "%s"' % inspect.getframeinfo(frame)[2]
for i in args:
print " %s = %s" % (i, values[i])
return [(i, values[i]) for i in args]
>>> func(1, 2, 3)
function name "func"
a = 1
b = 2
c = 3
[('a', 1), ('b', 2), ('c', 3)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment