-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
cpython/Doc/reference/compound_stmts.rst
Lines 1211 to 1224 in 2f5c3b0
| .. productionlist:: python-grammar | |
| funcdef: [`decorators`] "def" `funcname` [`type_params`] "(" [`parameter_list`] ")" | |
| : ["->" `expression`] ":" `suite` | |
| decorators: `decorator`+ | |
| decorator: "@" `assignment_expression` NEWLINE | |
| parameter_list: `defparameter` ("," `defparameter`)* "," "/" ["," [`parameter_list_no_posonly`]] | |
| : | `parameter_list_no_posonly` | |
| parameter_list_no_posonly: `defparameter` ("," `defparameter`)* ["," [`parameter_list_starargs`]] | |
| : | `parameter_list_starargs` | |
| parameter_list_starargs: "*" [`parameter`] ("," `defparameter`)* ["," ["**" `parameter` [","]]] | |
| : | "**" `parameter` [","] | |
| parameter: `identifier` [":" `expression`] | |
| defparameter: `parameter` ["=" `expression`] | |
| funcname: `identifier` |
In parameter_list_starargs - everything can be optional, except for *, and that permits incorrect function definitions like def foo(*):
>>> def foo(*): pass
File "<stdin>", line 1
def foo(*): pass
^
SyntaxError: named arguments must follow bare *See d.p.o thread https://discuss.python.org/t/56998. I'll provide a patch, based on suggested solution.
CC @norpadon
Linked PRs
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir