why objects of old style classes are instances of 'object'

Diez B. Roggisch deets at nospam.web.de
Thu Apr 17 17:07:29 CEST 2008


AlFire wrote:

> Hi,
> 
> Q: from the subject, why objects of old style classes are instances of
> 'object'?
> 
>  >>> class a():pass
>  >>> A=a()
>  >>> isinstance(A,object)
> 
> True

Because everything is an object.

But not everything is a newstyle-class:

>>> class Foo: pass
...
>>> isinstance(Foo, object)
True
>>> isinstance(Foo, type)
False
>>> class Bar(object): pass
...
>>> isinstance(Bar, type)
True
>>>                         


Diez



More information about the Python-list mailing list