(func, /, *positional, **named)
return arg2value
Get the mapping of arguments to values.

    A dict is returned, with keys the function argument names (including the
    names of the * and ** arguments, if any), and values the respective bound
    values from 'positional' and 'named'.
Get the mapping of arguments to values.
Get the mapping of arguments to values .
def getcallargs(func, /, *positional, **named):
    """Get the mapping of arguments to values.

    A dict is returned, with keys the function argument names (including the
    names of the * and ** arguments, if any), and values the respective bound
    values from 'positional' and 'named'."""
    spec = getfullargspec(func)
    args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = spec
    f_name = func.__name__
    arg2value = {}


    if ismethod(func) and func.__self__ is not None:
        # implicit 'self' (or 'cls' for classmethods) argument
        positional = (func.__self__,) + positional
    num_pos = len(positional)
    num_args = len(args)
    num_defaults = len(defaults) if defaults else 0

    n = min(num_pos, num_args)
    for i in range(n):
        arg2value[args[i]] = positional[i]
    if varargs:
        arg2value[varargs] = tuple(positional[n:])
    possible_kwargs = set(args + kwonlyargs)
    if varkw:
        arg2value[varkw] = {}
    for kw, value in named.items():
        if kw not in possible_kwargs:
            if not varkw:
                raise TypeError("%s() got an unexpected keyword argument %r" %
                                (f_name, kw))
            arg2value[varkw][kw] = value
            continue
        if kw in arg2value:
            raise TypeError("%s() got multiple values for argument %r" %
                            (f_name, kw))
        arg2value[kw] = value
    if num_pos > num_args and not varargs:
        _too_many(f_name, args, kwonlyargs, varargs, num_defaults,
                   num_pos, arg2value)
    if num_pos < num_args:
        req = args[:num_args - num_defaults]
        for arg in req:
            if arg not in arg2value:
                _missing_arguments(f_name, req, True, arg2value)
        for i, arg in enumerate(args[num_args - num_defaults:]):
            if arg not in arg2value:
                arg2value[arg] = defaults[i]
    missing = 0
    for kwarg in kwonlyargs:
        if kwarg not in arg2value:
            if kwonlydefaults and kwarg in kwonlydefaults:
                arg2value[kwarg] = kwonlydefaults[kwarg]
            else:
                missing += 1
    if missing:
        _missing_arguments(f_name, kwonlyargs, False, arg2value)
    return arg2value
def getcallargs ( func , / , * positional , * * named ) : spec = getfullargspec ( func ) args , varargs , varkw , defaults , kwonlyargs , kwonlydefaults , ann = spec f_name = func . __name__ arg2value = { } if ismethod ( func ) and func . __self__ is not None : # implicit 'self' (or 'cls' for classmethods) argument positional = ( func . __self__ , ) + positional num_pos = len ( positional ) num_args = len ( args ) num_defaults = len ( defaults ) if defaults else 0 n = min ( num_pos , num_args ) for i in range ( n ) : arg2value [ args [ i ] ] = positional [ i ] if varargs : arg2value [ varargs ] = tuple ( positional [ n : ] ) possible_kwargs = set ( args + kwonlyargs ) if varkw : arg2value [ varkw ] = { } for kw , value in named . items ( ) : if kw not in possible_kwargs : if not varkw : raise TypeError ( "%s() got an unexpected keyword argument %r" % ( f_name , kw ) ) arg2value [ varkw ] [ kw ] = value continue if kw in arg2value : raise TypeError ( "%s() got multiple values for argument %r" % ( f_name , kw ) ) arg2value [ kw ] = value if num_pos > num_args and not varargs : _too_many ( f_name , args , kwonlyargs , varargs , num_defaults , num_pos , arg2value ) if num_pos < num_args : req = args [ : num_args - num_defaults ] for arg in req : if arg not in arg2value : _missing_arguments ( f_name , req , True , arg2value ) for i , arg in enumerate ( args [ num_args - num_defaults : ] ) : if arg not in arg2value : arg2value [ arg ] = defaults [ i ] missing = 0 for kwarg in kwonlyargs : if kwarg not in arg2value : if kwonlydefaults and kwarg in kwonlydefaults : arg2value [ kwarg ] = kwonlydefaults [ kwarg ] else : missing += 1 if missing : _missing_arguments ( f_name , kwonlyargs , False , arg2value ) return arg2value