Everything is an object in python - object class and type class

Terry Reedy tjreedy at udel.edu
Sun May 31 11:37:08 EDT 2015


On 5/31/2015 10:34 AM, Eddilbert Macharia wrote:

> I'm wrecking my head trying to understand. where the class object comes into play .

Leaving custom metaclasses aside.

1. All python data values are instances of some class.

2. Every class is a instance of the metaclass 'type'.

3. Every class is a subclass of the base class 'object'.

Some implications.

4. All objects, including classes, get their basic instance behaviors 
from 'object', except as over-riden by other classes in the inheritance 
chain.  These basic behaviors include default comparisons and 
representations.  See 'dir(object)'.

5. Classes get their special class behaviors from 'type'.

-- 
Terry Jan Reedy




More information about the Python-list mailing list