diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2020-03-07 18:23:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-07 18:23:49 (GMT) |
commit | 8f130536926a30237b5297780d61ef4232e88577 (patch) | |
tree | 8e687168c1ea7a3311ae853bf944ae195d194b52 /Doc/reference | |
parent | 02f64cb79175902705b40e3eaa8ea6c7038754ef (diff) | |
download | cpython-8f130536926a30237b5297780d61ef4232e88577.zip cpython-8f130536926a30237b5297780d61ef4232e88577.tar.gz cpython-8f130536926a30237b5297780d61ef4232e88577.tar.bz2 |
bpo-39702: Update the Language Reference (PEP 614) (GH-18802)
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/compound_stmts.rst | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index ac2065b..c14e7c7 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -507,7 +507,7 @@ A function definition defines a user-defined function object (see section funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" : ["->" `expression`] ":" `suite` decorators: `decorator`+ - decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE + decorator: "@" `assignment_expression` NEWLINE dotted_name: `identifier` ("." `identifier`)* parameter_list: `defparameter` ("," `defparameter`)* "," "/" ["," [`parameter_list_no_posonly`]] : | `parameter_list_no_posonly` @@ -550,6 +550,11 @@ is roughly equivalent to :: except that the original function is not temporarily bound to the name ``func``. +.. versionchanged:: 3.9 + Functions may be decorated with any valid :token:`assignment_expression`. + Previously, the grammar was much more restrictive; see :pep:`614` for + details. + .. index:: triple: default; parameter; value single: argument; function definition @@ -717,6 +722,11 @@ is roughly equivalent to :: The evaluation rules for the decorator expressions are the same as for function decorators. The result is then bound to the class name. +.. versionchanged:: 3.9 + Classes may be decorated with any valid :token:`assignment_expression`. + Previously, the grammar was much more restrictive; see :pep:`614` for + details. + **Programmer's note:** Variables defined in the class definition are class attributes; they are shared by instances. Instance attributes can be set in a method with ``self.name = value``. Both class and instance attributes are |