I have a basic understanding of python. Can anybody tell me what is the relation between 'type' and 'object' (I know that type
is sub-class of object
).
Because when we execute the following statements in interpreter, the output is confusing about their relationship with each other i.e. how they resolve this confusion.
1)
type(object)
<type 'type'>
>>> type(type)
<type 'type'>
By seeing the above result we can say that type of 'object' is 'type', and type of 'type' is also 'type'.
2) The same result as above can be achieved by this also.
type.__class__
<type 'type'>
>>> object.__class__
<type 'type'>
And by observing this we can say that class object is of type 'type' and class 'type' is type of itself. 3)
object.__bases__
()
>>> type.__bases__
(<type 'object'>,)
But when I go for superclasses of each, I found that object is superclass of all classes in New-style class system, while type is subclass of object.
I only want to know the relationship between these two classes. How they are connected to each other. Can anybody suggest me any good study material to get into python internals.