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

Erno Kuusela erno-news at erno.iki.fi
Wed Apr 10 22:28:34 EDT 2002


In article <slrnab9o7v.i8b.huaiyu at gauss.almadan.ibm.com>,
huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) writes:

| 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?

no, it is a regular (new-style) 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 ...

no, it is an is an instance of x (and by implication, its type
is x).

  -- erno



More information about the Python-list mailing list