Created
October 1, 2015 22:01
-
-
Save stinoga/86351c5368e3e45c2546 to your computer and use it in GitHub Desktop.
List Arguments in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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