@@ -507,7 +507,7 @@ A function definition defines a user-defined function object (see section
507
507
funcdef: [`decorators `] "def" `funcname ` "(" [`parameter_list `] ")"
508
508
: ["->" `expression `] ":" `suite `
509
509
decorators: `decorator`+
510
- decorator: "@" `dotted_name ` ["(" [` argument_list ` [","]] ")"] NEWLINE
510
+ decorator: "@" `assignment_expression ` NEWLINE
511
511
dotted_name: `identifier ` ("." `identifier `)*
512
512
parameter_list: `defparameter ` ("," `defparameter `)* "," "/" ["," [`parameter_list_no_posonly `]]
513
513
: | `parameter_list_no_posonly `
@@ -550,6 +550,11 @@ is roughly equivalent to ::
550
550
551
551
except that the original function is not temporarily bound to the name ``func ``.
552
552
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
+
553
558
.. index ::
554
559
triple: default; parameter; value
555
560
single: argument; function definition
@@ -717,6 +722,11 @@ is roughly equivalent to ::
717
722
The evaluation rules for the decorator expressions are the same as for function
718
723
decorators. The result is then bound to the class name.
719
724
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
+
720
730
**Programmer's note: ** Variables defined in the class definition are class
721
731
attributes; they are shared by instances. Instance attributes can be set in a
722
732
method with ``self.name = value ``. Both class and instance attributes are
0 commit comments