type() for new style classes - buggy?

Sidharth Kuruvila sidharthk at hotmail.com
Wed Jan 28 09:57:02 EST 2004



In the case of new style classes type actually doubles up as a class
constructor, so all classes including type itself are instances type.

>>> class A(object):
...  pass
...
>>> a = A()
>>> type(a)
<class '__main__.A'>
>>> type(A)
<type 'type'>
>>> isinstance(A, type)
True
>>> isinstance(a, type)
False
>>> isinstance(type, type)
True
>>>

hope this helps
there is some documentation on new style classes you might want to read.
http://www.python.org/doc/newstyle.html
particularly the first essay by Guido.







More information about the Python-list mailing list