Runtime Data Attributes

code.co_argcount

Number of positional parameters, including positional-only and positional-or-keyword parameters, excluding keyword-only and variadic parameters.

Formal Syntax & Structure

python syntaxpython
code.co_argcount

Return Value

int

Value exposed by this attribute; availability and mutability depend on the owner as described.

Working Example

Example Snippetpython
def f(a, /, b=2, *args, c=3, **kw): passcode = f.__code__print(code.co_argcount)
Python Reference