My program derives a sequence args
and a mapping kwargs
from user input. I want to check that input, and then forward it to a python function f
(which is chosen based on user input). In this case, a function signature mismatch between f
and [kw]args
is an input error; I must distinguish it from possible programming errors within the implementation of f
, even though they might both raise TypeError
.
So I want to check the signature before attempting the function call. Is there a way to do this other than to manually compare [kw]args
to the result of inspect.getargspec
(or .getfullargspec
or .signature
in later python versions)?
Related questions: Is there a way to check a function's signature in Python?