Calls
A call calls a callable object (e.g. a function) with a possibly empty series of arguments:
Syntax:
primary ( argument list [,] )
[primary
call ::= [ primary][1] “(” [[argument_list][2] [“,”]] “)”
“(” [[argument_list][2] [“,”] | [test][3] [ genexpr_for][4] ] “)”
argument_list ::= [positional_arguments][5] [“,” [keyword_arguments][6]]
["," "\*" [ expression][7]]
["," "\*\*" [ expression][7]]
| [keyword\_arguments][6] ["," "\*" [ expression][7]]
["," "\*\*" [ expression][7]]
| "\*" [expression][7] ["," "\*\*" [ expression][7]]
| "\*\*" [expression][7]
positional_arguments ::= [ expression][7] (“,” [expression][7])*
keyword_arguments ::= [ keyword_item][8] (“,” [keyword_item][8])*
keyword_item ::= [ identifier][9] “=” [expression][7]
A trailing comma may be present after the positional and keyword arguments but does not affect the semantics.
The primary must evaluate to a callable object (user-defined functions, built-in functions, methods of built-in objects, class objects, methods of class instances, and certain class instances themselves are callable; extensions may define additional callable object types). All argument expressions are evaluated before the call is attempted. Please refer to section [7.6][11] for the syntax of formal parameter lists.
If keyword arguments are present, they are first converted to positional arguments, as follows. First, a list of unfilled slots is created for the formal parameters. If there are N positional arguments, they are placed in the first N slots. Next, for each keyword argument, the identifier is used to determine the corresponding slot (if the identifier is the same as the first formal parameter name, the first slot is used, and so on). If the slot is already filled, a