Tuesday, 20 August 2013

Knowing length of input argument of a function in python

Knowing length of input argument of a function in python

Let's say now I have a function:
def func(x, p): return p[0] * x ** 2 + p[1] * x + p[2]
And now, I can get the information about the function using inspect:
import inspect
args, varargs, varkw, defaults = inspect.getargspec(func)
But I only know I have two arguments, instead of the information on each
argument (whether it's a scalar or something else).
Just making sure - theoretically, is there any way that I can know the
minimum length of the tuple p used in the function?
Thank you!

No comments:

Post a Comment