-1
python2.7issubclass(type,type)=爲什麼?
>>> issubclass(type,type)
True
>>> issubclass(object,object)
True
>>> issubclass(object,type)
False
我知道object
是新式類的頂部,所以type
從object
繼承。由於object
本身就是其子類。現在,我可以得到一個鏈條是這樣的: type
- >object
- >object
- X->type
。 issubclass(type,type)
怎麼可能是True
?
我會建議有關這個主題的優秀文章:http://www.cafepy.com/article/python_types_and_objects /python_types_and_objects.html#bring-in-the-objects – ewcz
另請參閱http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python –