>>> class Foo:pass
>>> foo = Foo()
>>> type(Foo)
<type 'classobj'>
>>> type(foo)
<type 'instance'>
>>> class Bar(object):pass
>>> bar = Bar()
>>> type(Bar)
<type 'type'>
>>> type(bar)
<class '__main__.Bar'>
为何type(Foo) 返回是<type 'classobj'>
而 type(Bar) <type 'type'>
type(foo) 返回<type 'instance'> 而type(bar) 返回<class '__main__.Bar'>
python2.2引入了new-style class.如果一个类继承了object对象,那么它就是一个new-style class.
内建的object对象.
object类是所有new-style class的祖先.object对象定义了一系列特殊的方法来实现所有对象的默认行为.
静态方法__new__用来创造类的实例.__init__方法用来初始化自己.