params.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:cauldron 作者: sernst 项目源码 文件源码
def get_args_index(target) -> int:
    """
    Returns the index of the "*args" parameter if such a parameter exists in
    the function arguments or -1 otherwise.

    :param target:
        The target function for which the args index should be determined
    :return:
        The arguments index if it exists or -1 if not
    """

    code = target.__code__

    if not bool(code.co_flags & inspect.CO_VARARGS):
        return -1

    return code.co_argcount + code.co_kwonlyargcount
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号