@@ -507,7 +507,7 @@ A function definition defines a user-defined function object (see section
507507 funcdef: [`decorators `] "def" `funcname ` "(" [`parameter_list `] ")"
508508 : ["->" `expression `] ":" `suite `
509509 decorators: `decorator`+
510- decorator: "@" `dotted_name ` ["(" [` argument_list ` [","]] ")"] NEWLINE
510+ decorator: "@" `assignment_expression ` NEWLINE
511511 dotted_name: `identifier ` ("." `identifier `)*
512512 parameter_list: `defparameter ` ("," `defparameter `)* "," "/" ["," [`parameter_list_no_posonly `]]
513513 : | `parameter_list_no_posonly `
@@ -550,6 +550,11 @@ is roughly equivalent to ::
550550
551551except that the original function is not temporarily bound to the name ``func ``.
552552
553+ .. versionchanged :: 3.9
554+ Functions may be decorated with any valid :token: `assignment_expression `.
555+ Previously, the grammar was much more restrictive; see :pep: `614 ` for
556+ details.
557+
553558.. index ::
554559 triple: default; parameter; value
555560 single: argument; function definition
@@ -717,6 +722,11 @@ is roughly equivalent to ::
717722The evaluation rules for the decorator expressions are the same as for function
718723decorators. The result is then bound to the class name.
719724
725+ .. versionchanged :: 3.9
726+ Classes may be decorated with any valid :token: `assignment_expression `.
727+ Previously, the grammar was much more restrictive; see :pep: `614 ` for
728+ details.
729+
720730**Programmer's note: ** Variables defined in the class definition are class
721731attributes; they are shared by instances. Instance attributes can be set in a
722732method with ``self.name = value ``. Both class and instance attributes are
0 commit comments