hasarg
(func
, arg
)
Checks if a function has a given argument.
Works with args and kwargs as well if you exclude the
stars. See example below.
Parameters¶
func: function
arg: str
Name of argument to look for.
Returns¶
bool
Example¶
def foo(a, b=6, *args):
return
hasarg(foo, 'b')
True
hasarg(foo, 'args')
True
hasarg(foo, 'c')
False