kind
Describes how argument values are bound to the parameter. Possible values (accessible via Parameter, like Parameter.KEYWORD_ONLY):
| Name | Meaning |
|---|---|
| POSITIONAL_ONLY |
Value must be supplied as a positional argument. Python has no explicit syntax for defining positional-only parameters, but many built-in and extension module functions (especially those that accept only one or two parameters) accept them. |
| POSITIONAL_OR_KEYWORD | Value may be supplied as either a keyword or positional argument (this is the standard binding behaviour for functions implemented in Python.) |
| VAR_POSITIONAL | A tuple of positional arguments that aren’t bound to any other parameter. This corresponds to a *args parameter in a Python function definition. |
| KEYWORD_ONLY | Value must be supplied as a keyword argument. Keyword only parameters are those which appear after a * or *args entry in a Python function definition. |
| VAR_KEYWORD | A dict of keyword arguments that aren’t bound to any other parameter. This corresponds to a **kwargs parameter in a Python function definition. |
Example: print all keyword-only arguments without default values:
>>> def foo(a, b, *, c, d=10):
... pass
>>> sig = signature(foo)
>>> for param in sig.parameters.values():
... if (param.kind == param.KEYWORD_ONLY and
... param.default is param.empty):
... print('Parameter:', param)
Parameter: c
Please login to continue.