omitargs( = = = these only failthoughwhere we try to invoke the original functionat the end of the wrapper while we could try to imitate python' argument matching to avoid thisthere' not much reason to do so--since the call would fail at this point anyhowwe might as well let python' own argument-matching logic detect the problem for us arbitrary arguments secondalthough our final version handles positional argumentskeyword argumentsand omitted defaultsit still doesn' do anything explicit about *pargs and **kargs starred-argument names that may be used in decorated function that accepts arbitrarily many arguments itself we probably don' need to care for our purposesthoughif an extra keyword argument is passedits name will show up in **kargs and can be tested normally if mentioned to the decorator if an extra keyword argument is not passedits name won' be in either **kargs or the sliced expected positionals listand it will thus not be checked--it is treated as though it were defaultedeven though it is really an optional extra argument if an extra positional argument is passedthere' no way to reference it in the decorator anyhow--its name won' be in either **kargs or the sliced expected arguments listso it will simply be skipped because such arguments are not listed in the function' definitionthere' no way to map name given to the decorator back to an expected relative position in other wordsas it is the code supports testing arbitrary keyword arguments by namebut not arbitrary positionals that are unnamed and hence have no set position in the function' argument signature in terms of the function object' apihere' the effect of these tools in decorated functionsdef func(*kargs**pargs)pass code func __code__ code co_nlocalscode co_varnames ( ('kargs''pargs')code co_argcountcode co_varnames[:code co_argcount( ()def func(ab*kargs**pargs)pass code func __code__ code co_argcountcode co_varnames[:code co_argcount( (' '' ')because starred-argument names show up as locals but not as expected argumentsthey won' be factor in our matching algorithm--names preceding them in function headers can be validated as usualbut not any extra positional arguments passed in principlewe could extend the decorator' interface to support *pargs in the decorated functiontoofor the rare cases where this might be useful ( special argument examplevalidating function arguments