type() new style class instance says "class", not "ObjectType"

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Wed Apr 10 21:04:02 EDT 2002


On Wed, 10 Apr 2002 18:38:47 -0400, Brad Clements <bkc at Murkworks.com> wrote:
>>>> class x(object):
>...  pass
>...
>>>> y = x()
>>>> type(y)
><class '__main__.x'>

Is this a bug?  Is x a meta class?

>>> y.__class__ 
<class '__main__.x'>
>>> z = y()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'x' object is not callable

Is y a class?  I'm puzzled ...

>
>>>> type(x)
><type 'type'>

This is OK:

>>> isinstance (x, TypeType )
1

Huaiyu



More information about the Python-list mailing list