Knowing length of input argument of a function in python -
let's have function:
def func(x, p): return p[0] * x ** 2 + p[1] * x + p[2]
and now, can information function using inspect:
import inspect args, varargs, varkw, defaults = inspect.getargspec(func)
but know have 2 arguments, instead of information on each argument (whether it's scalar or else).
just making sure - theoretically, there way can know minimum length of tuple p used in function?
thank you!
the answer no.
firstly can't assume type (let alone size of argument).
secondly, there no way tell length, because it's supposed arbitrary , function may nothing input @ all.
if want similar, try use *l variable-length arguments. there **d arbitrary map (named arguments).
Comments
Post a Comment