[Python-checkins] r61366 - python/trunk/Doc/reference/compound_stmts.rst
andrew.kuchling
python-checkins at python.org
Thu Mar 13 12:07:35 CET 2008
Author: andrew.kuchling
Date: Thu Mar 13 12:07:35 2008
New Revision: 61366
Modified:
python/trunk/Doc/reference/compound_stmts.rst
Log:
Add class decorators
Modified: python/trunk/Doc/reference/compound_stmts.rst
==============================================================================
--- python/trunk/Doc/reference/compound_stmts.rst (original)
+++ python/trunk/Doc/reference/compound_stmts.rst Thu Mar 13 12:07:35 2008
@@ -50,6 +50,7 @@
: | `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 @@
: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 @@
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
More information about the Python-checkins
mailing list