明星*在函数声明中的含义是什么?

ste*_*nci 7 python syntax parameter-passing

*以下代码(在pprint库中找到)的含义是什么?

def pformat(object, indent=1, width=80, depth=None, *, compact=False):
    """Format a Python object into a pretty-printed representation."""
    return PrettyPrinter(indent=indent, width=width, depth=depth,
                         compact=compact).pformat(object)
Run Code Online (Sandbox Code Playgroud)

如果是*args那么它将是任意数量的位置参数.参数值将在名为的元组中args.前4个参数可以按名称或按位置compact分配,参数只能按名称分配...

好吧,不!因为它不符合文档:

在函数调用中,关键字参数必须遵循位置参数.

那么,明星在其他命名参数之前和之后做了什么?那是怎么用的?或者为什么不使用它?

Bre*_*arn 11

当没有变量参数时,它将位置参数与仅关键字参数分开.这是仅限Python-3的功能.