type(type) is an object, not an instance

Sip sip at email.ee
Tue Mar 18 21:09:22 EST 2003


I don't know if this can be called a bug, but type(type) is the type 
object, not an instance of it, like type of other types:
>>> type(type) is type
1
>>> type(int) is int
0


type(type) is an object, therefore its methods are unbound, so this will 
raise an error:
>>> type(type).mro()
Traceback (most recent call last):
  File "<input>", line 1, in ?
TypeError: descriptor 'mro' of 'type' object needs an argument


But type.mro works, if you specify the self argument manually:
>>> type(type).mro(type)
>>> type.mro(type)
[<type 'type'>, <type 'object'>]


sipsick





More information about the Python-list mailing list