@@ -1208,18 +1208,15 @@ A function definition defines a user-defined function object (see section
12081208:ref: `types `):
12091209
12101210.. productionlist :: python-grammar
1211- funcdef: [`decorators `] "def" `funcname ` [`type_params `] "(" [`parameter_list `] ")"
1212- : ["->" `expression `] ":" `suite `
1211+ funcdef: [`decorators `] "def" `funcname ` [`type_params `] "(" [`parameter_list `] ")" : ["->" `expression `] ":" `suite `
12131212 decorators: `decorator`+
12141213 decorator: "@" `assignment_expression ` NEWLINE
1215- parameter_list: `defparameter ` ("," `defparameter `)* "," "/" ["," [`parameter_list_no_posonly `]]
1216- : | `parameter_list_no_posonly `
1217- parameter_list_no_posonly: `defparameter ` ("," `defparameter `)* ["," [`parameter_list_starargs `]]
1218- : | `parameter_list_starargs `
1219- parameter_list_starargs: "*" [`parameter `] ("," `defparameter `)* ["," ["**" `parameter ` [","]]]
1220- : | "**" `parameter ` [","]
12211214 parameter: `identifier ` [":" `expression `]
1215+ star_parameter: `identifier ` [":" ["*"] `expression `]
12221216 defparameter: `parameter ` ["=" `expression `]
1217+ parameter_list: `defparameter ` ("," `defparameter `)* "," "/" ["," [`parameter_list_no_posonly `]] : | `parameter_list_no_posonly `
1218+ parameter_list_no_posonly: `defparameter ` ("," `defparameter `)* ["," [`parameter_list_starargs `]] : | `parameter_list_starargs `
1219+ parameter_list_starargs: "*" [`star_parameter `] ("," `defparameter `)* ["," ["**" `parameter ` [","]]] : | "**" `parameter ` [","]
12231220 funcname: `identifier `
12241221
12251222
@@ -1323,9 +1320,11 @@ and may only be passed by positional arguments.
13231320 single: ->; function annotations
13241321 single: : (colon); function annotations
13251322
1326- Parameters may have an :term: `annotation <function annotation> ` of the form "``: expression ``"
1327- following the parameter name. Any parameter may have an annotation, even those of the form
1328- ``*identifier `` or ``**identifier ``. Functions may have "return" annotation of
1323+ Parameters may have an :term: `annotation <function annotation> ` of the form
1324+ "``: expression ``" following the parameter name. Any parameter may have an
1325+ annotation, even those of the form ``*identifier `` or ``**identifier ``.
1326+ (As a special case, parameters of the form ``*identifier `` may have an
1327+ annotation "``: *expression ``".) Functions may have "return" annotation of
13291328the form "``-> expression ``" after the parameter list. These annotations can be
13301329any valid Python expression. The presence of annotations does not change the
13311330semantics of a function. The annotation values are available as values of
@@ -1336,6 +1335,10 @@ enables postponed evaluation. Otherwise, they are evaluated when the function
13361335definition is executed. In this case annotations may be evaluated in
13371336a different order than they appear in the source code.
13381337
1338+ .. versionchanged :: 3.11
1339+ Parameters of the form "``*args ``" may have an annotation
1340+ "``: *expression ``". See :pep: `646 ` for details.
1341+
13391342.. index :: pair: lambda; expression
13401343
13411344It is also possible to create anonymous functions (functions not bound to a
0 commit comments