summaryrefslogtreecommitdiffstats
path: root/Doc/reference/compound_stmts.rst
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2008-03-13 11:07:35 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2008-03-13 11:07:35 (GMT)
commitd51e842a3ff325730ff93a8c9ad22b1d3bdf77e2 (patch)
tree6606ad3710177c14d459c642e620d1082126e412 /Doc/reference/compound_stmts.rst
parent2e25551ef864e8024659d9d8859a7113d14de9e8 (diff)
downloadcpython-d51e842a3ff325730ff93a8c9ad22b1d3bdf77e2.zip
cpython-d51e842a3ff325730ff93a8c9ad22b1d3bdf77e2.tar.gz
cpython-d51e842a3ff325730ff93a8c9ad22b1d3bdf77e2.tar.bz2
Add class decorators
Diffstat (limited to 'Doc/reference/compound_stmts.rst')
-rw-r--r--Doc/reference/compound_stmts.rst9
1 files changed, 8 insertions, 1 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 076c284..be1d10e 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -50,6 +50,7 @@ Summarizing:
: | `with_stmt`
: | `funcdef`
: | `classdef`
+ : | `decorated`
suite: `stmt_list` NEWLINE | NEWLINE INDENT `statement`+ DEDENT
statement: `stmt_list` NEWLINE | `compound_stmt`
stmt_list: `simple_stmt` (";" `simple_stmt`)* [";"]
@@ -400,9 +401,10 @@ A function definition defines a user-defined function object (see section
:ref:`types`):
.. productionlist::
- funcdef: [`decorators`] "def" `funcname` "(" [`parameter_list`] ")" ":" `suite`
+ decorated: decorators (classdef | funcdef)
decorators: `decorator`+
decorator: "@" `dotted_name` ["(" [`argument_list` [","]] ")"] NEWLINE
+ funcdef: "def" `funcname` "(" [`parameter_list`] ")" ":" `suite`
dotted_name: `identifier` ("." `identifier`)*
parameter_list: (`defparameter` ",")*
: ( "*" `identifier` [, "**" `identifier`]
@@ -529,6 +531,11 @@ mutable values there can lead to unexpected results. For :term:`new-style
class`\es, descriptors can be used to create instance variables with different
implementation details.
+Class definitions, like function definitions, may be wrapped by one or
+more :term:`decorator` expressions. The evaluation rules for the
+decorator expressions are the same as for functions. The result must
+be a class object, which is then bound to the class name.
+
.. rubric:: Footnotes
.. [#] The exception is propagated to the invocation stack only if there is no