def _parse_pathargs(path_args, args, kwargs, argspec):
    """
    `path_args`, iterable: Which args/kwargs to use, in order. Numbers are
        args, strings are kwargs.
    `args`, `kwargs`: The value of args/kwargs passed to the original builder
        function.
    `argspec`: Stores values of default kwargs from builder function.
    """
    patharg_values = []
    argnames = argspec.args
    defaults = argspec.defaults
    for arg in path_args:
        arg_type = type(arg)
        if arg_type is int:
            patharg_values.append(args[arg])
        elif arg_type is str:
            try:
                patharg_values.append(kwargs[arg])
            except KeyError:
                nargs = len(argnames) - len(defaults)
                kwarg_idx = argnames.index(arg) - nargs
                patharg_values.append(defaults[kwarg_idx])
        else:
            raise ValueError('Path arg must be int or str.')
    return patharg_values
