A class definition defines a class object.
Syntax:
or
class name ( inheritance expression list ):
suite
or
A class definition is an executable statement. It first evaluates the inheritance list, if present. Each item in the inheritance list (an ordinary expression list) should evaluate to a class object or class type which allows subclassing.
The class definition then sets up a new execution frame (see naming-and-binding), using a newly created local namespace and the original global namespace, and uses that to execute the statements in the suite. (Usually, the suite contains only function definitions.)
When the suite finishes execution, the execution frame is discarded but its local namespace is saved. A class object is then created using the inheritance list for the base classes and the saved local namespace for the attribute dictionary. Finally, the class name is bound to this class object in the original local namespace.
Programmer's note: Variables defined in the
class definition are class variables; they are shared by all
instances. To define instance variables, they must be given a value
in the __init__ method or
in another method. Both class and instance variables are accessible
through the notation self.name, and an instance
variable hides a class variable with the same name when accessed in
this way. Class variables with immutable values can be used as
defaults for instance variables. For new-style classes, descriptors can be
used to create instance variables with different implementation
details.