Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f414272

Browse files
committed
#9117: fix syntax for class definition.
1 parent e0bf91d commit f414272

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Doc/reference/compound_stmts.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,9 @@ A class definition defines a class object (see section :ref:`types`):
555555

556556
.. productionlist::
557557
classdef: [`decorators`] "class" `classname` [`inheritance`] ":" `suite`
558-
inheritance: "(" [`argument_list` [","] ] ")"
558+
inheritance: "(" [`argument_list` [","] | `comprehension`] ")"
559559
classname: `identifier`
560560

561-
562561
A class definition is an executable statement. The inheritance list usually
563562
gives a list of base classes (see :ref:`metaclasses` for more advanced uses), so
564563
each item in the list should evaluate to a class object which allows
@@ -575,7 +574,7 @@ namespace.
575574

576575
Class creation can be customized heavily using :ref:`metaclasses <metaclasses>`.
577576

578-
Classes can also be decorated; as with functions, ::
577+
Classes can also be decorated: just like when decorating functions, ::
579578

580579
@f1(arg)
581580
@f2
@@ -586,6 +585,10 @@ is equivalent to ::
586585
class Foo: pass
587586
Foo = f1(arg)(f2(Foo))
588587

588+
The evaluation rules for the decorator expressions are the same as for function
589+
decorators. The result must be a class object, which is then bound to the class
590+
name.
591+
589592
**Programmer's note:** Variables defined in the class definition are class
590593
attributes; they are shared by instances. Instance attributes can be set in a
591594
method with ``self.name = value``. Both class and instance attributes are

0 commit comments

Comments
 (0)