Skip to content

Instantly share code, notes, and snippets.

@ericdill
Created August 13, 2014 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericdill/7f21da1b5950b6096630 to your computer and use it in GitHub Desktop.
Save ericdill/7f21da1b5950b6096630 to your computer and use it in GitHub Desktop.
def foo(var1=None, var2=False, var3=None, var4=None):
# get the number of input arguments
argcount = foo.func_code.co_argcount
# get the names of those input arguments
varnames = search.func_code.co_varnames[:argcount]
# get the values of those input arguments
# ???
# I can programatically do it by:
varvals = [var1, var2, var3, var4]
# and then create a dictionary by:
var_dict = {}
for name, val in zip(varnames, varvals):
var_dict[name] = val
# but do I have to know the names of the input parameters to create
# the list on line 9?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment