Hello All ,

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

Is it only meant to act as base class and does it mean there is an actual class 
called object in python which all the objects created using the class type 
inherit ?

i'm assuming the metaclass if simplified would look something like this :

type('dict', (object,),{})

And when we use the class type as a metaclass are we using the instance version 
of the class type or are we actually using the type class itself ?

Also when we say everything is an object in python, are we referring to the 
fact that everything is an instance of the class type or does it have to with 
the object class inherited ? 

As can be attested by using type() function as below :

>>> type(int)
<class 'type'>
>>> type(list)
<class 'type'>
>>> type(dict)
<class 'type'>
>>> type(type)
<class 'type'>
>>> type(object)
<class 'type'>

>From my understanding this means all of this are instances of the class type. 
>which means the class type was used to create this instances.

Now if i look at the __bases__ of all this objects i get :

>>> type.__base__
<class 'object'>
>>> type.__bases__
(<class 'object'>,)
>>> dict.__bases__
(<class 'object'>,)
>>> list.__bases__
(<class 'object'>,)
>>> int.__bases__
(<class 'object'>,)
>>> object.__bases__
()

This tells me that all of this objects inherit from the class object which has 
nothing to do with them being instances.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to