Skip to content

Commit 2348afd

Browse files
committed
- update to reflect that base classes can be class types as well as
"classic" class objects [partially fixes SF bug #453684] - add note that new-style classes can use descriptors to implement instance variables in different ways
1 parent 16434b5 commit 2348afd

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Doc/ref/ref7.tex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ \section{Class definitions\label{class}}
419419

420420
A class definition is an executable statement. It first evaluates the
421421
inheritance list, if present. Each item in the inheritance list
422-
should evaluate to a class object. The class's suite is then executed
422+
should evaluate to a class object or class type which allows
423+
subclassing. The class's suite is then executed
423424
in a new execution frame (see section~\ref{naming}), using a newly
424425
created local namespace and the original global namespace.
425426
(Usually, the suite contains only function definitions.) When the
@@ -433,11 +434,13 @@ \section{Class definitions\label{class}}
433434
\indexii{name}{binding}
434435
\indexii{execution}{frame}
435436

436-
\strong{Programmer's note:} variables defined in the class definition
437+
\strong{Programmer's note:} Variables defined in the class definition
437438
are class variables; they are shared by all instances. To define
438439
instance variables, they must be given a value in the
439440
\method{__init__()} method or in another method. Both class and
440441
instance variables are accessible through the notation
441442
``\code{self.name}'', and an instance variable hides a class variable
442443
with the same name when accessed in this way. Class variables with
443444
immutable values can be used as defaults for instance variables.
445+
For new-style classes, descriptors can be used to create instance
446+
variables with different implementation details.

0 commit comments

Comments
 (0)