Is type object an instance or class?

Dan Bishop danb_83 at yahoo.com
Mon Feb 26 23:00:53 EST 2007


On Feb 26, 8:00 pm, "JH" <john.... at sovereign.co.nz> wrote:
> Hi
>
> I found that a type/class are both a subclass and a instance of base
> type "object".
>
> It conflicts to my understanding that:
>
> 1.) a type/class object is created from class statement
> 2.) a instance is created by "calling" a class object.
>
> A object should not be both a class and an instance at the same time.
>
> Further I found out there is a special type call "type" that is a
> subclass of base type "object". All other types are instances of this
> type.  Even base type "object" is an instance of this special type.

Yes.  Python has a much broader definition of "object" than say, Java
does.  Functions are objects.  Modules are objects.  And most relevant
here, types are objects.  So "int" and even "object" are objects, and
they have type "type".

Confusing, I know, but perfectly logical.




More information about the Python-list mailing list