Next / Previous / Contents / TCC Help System / NM Tech homepage

26.1.1. Defining an old-style class

To define an old-style class C with no parent class, use this general form:

class C:
    ...class methods and variables...

To create a class that inherits from one or more parent classes P1, P2, …:

class C(P1, P2, ...):              
    ...class methods and variables...

As Python reads the definition of your class, it first creates a new, empty namespace called the class namespace. You can access the class namespace directly as an attribute named __dict__, a dictionary whose keys are the names in that namespace.

As Python reads each method or class variable in your class declaration, it adds the name of that method or variable to the class namespace.