Chapter 3. Wrap Up

The Python Objects Map

We really ended up with a map of different kinds of Python objects in the last chapter.

Figure 3.1. The Python Objects Map

The Python Objects Map

Here we also unravel the mystery of the vertical grey lines. They just segregate objects into three spaces based on what the common man calls them - metaclasses, classes, or instances.

Various pedantic observations of the diagram above:

  1. Dashed lines cross spacial boundaries (i.e. go from object to meta-object). Only exception is <type 'type'> (which is good, otherwise we would need another space to the left of it, and another, and another...).

  2. Solid lines do not cross space boundaries. Again, <type 'type'> -> <type 'object'> is an exception.

  3. Solid lines are not allowed in the rightmost space. These objects are too concrete to be subclassed.

  4. Dashed line arrow heads are not allowed rightmost space. These objects are too concrete to be instantiated.

  5. Left two spaces contain types. Rightmost space contains non-types.

  6. If we created a new object by subclassing <type 'type'> it would be in the leftmost space, and would also be both a subclass and instance of <type 'type'>.

Also note that <type 'type'> is indeed a type of all types, and <type 'object'> a superclass of all types (except itself).