Circular relationship: object - type

Chris Rebert clp2 at
Sun May 17 12:38:09 CEST 2009

On Thu, May 14, 2009 at 3:34 PM, Mohan Parthasarathy <suruti94 at> wrote:
> Hi,
> I have read several articles and emails:
>  I understand how type serves to be the default metaclass when an object is
> created and it also can be changed. I also read a few examples on why this
> metaclass can be a powerful concept. What I fail to understand is the
> circular relationship between object and type. Why does type have to be
> subclassed from object ? Just to make "Everything is an object and all
> objects are  inherited from object class".

Yes, essentially. It makes the system nice and axiomatic, so one
doesn't have to deal with special-cases when writing introspective

Axiom 1. All classes ultimately subclass the class `object`.
Equivalently, `issubclass(X, object) and X.__mro__[-1] is object` are
true for any class `X`, and `isinstance(Y, object)` is true for all
objects `Y`.

Axiom 2. All (meta)classes are ultimately instances of the (meta)class `type`.
Equivalently, repeated application of type() to any object will
eventually result in `type`.

Any other formulation besides Python's current one would break these
handy axioms. The canonical object-oriented language, Smalltalk, had a
nearly identical setup with regard to its meta-objects.


More information about the Python-list mailing list