[Python-checkins] r85626 - python/branches/py3k/Doc/reference/compound_stmts.rst

georg.brandl python-checkins at python.org
Sun Oct 17 12:38:20 CEST 2010


Author: georg.brandl
Date: Sun Oct 17 12:38:20 2010
New Revision: 85626

Log:
#9117: fix syntax for class definition.

Modified:
   python/branches/py3k/Doc/reference/compound_stmts.rst

Modified: python/branches/py3k/Doc/reference/compound_stmts.rst
==============================================================================
--- python/branches/py3k/Doc/reference/compound_stmts.rst	(original)
+++ python/branches/py3k/Doc/reference/compound_stmts.rst	Sun Oct 17 12:38:20 2010
@@ -555,10 +555,9 @@
 
 .. productionlist::
    classdef: [`decorators`] "class" `classname` [`inheritance`] ":" `suite`
-   inheritance: "(" [`argument_list` [","] ] ")"
+   inheritance: "(" [`argument_list` [","] | `comprehension`] ")"
    classname: `identifier`
 
-
 A class definition is an executable statement.  The inheritance list usually
 gives a list of base classes (see :ref:`metaclasses` for more advanced uses), so
 each item in the list should evaluate to a class object which allows
@@ -575,7 +574,7 @@
 
 Class creation can be customized heavily using :ref:`metaclasses <metaclasses>`.
 
-Classes can also be decorated; as with functions, ::
+Classes can also be decorated: just like when decorating functions, ::
 
    @f1(arg)
    @f2
@@ -586,6 +585,10 @@
    class Foo: pass
    Foo = f1(arg)(f2(Foo))
 
+The evaluation rules for the decorator expressions are the same as for function
+decorators.  The result must be a class object, which is then bound to the class
+name.
+
 **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


More information about the Python-checkins mailing list