Alex Rivera | Logout

How to find out the default values of a particular function's argument in another function in Python?

Asked 2011-02-01T07:28:11.730
12

Let's suppose we have a function like this:

def myFunction(arg1='a default value'):
  pass

We can use introspection to find out the names of the arguments that myFunction() takes using myFunction.func_code.co_varnames, but how to find out the default value of arg1 (which is 'a default value' in the above example)?

Edit
Report

1 Answer

0

My bad. Of course, there's myFunction.func_defaults.

answered 2011-02-01T07:33:47.207

Your Answer