关于python中的 object基类

In [1]:
class Foo(object):
    pass
class Foo1():
    pass
class Foo2:
    pass    

In [2]:
type(Foo),type(Foo1),type(Foo2)
Out[2]:
(type, classobj, classobj)

In [3]:
print dir(Foo)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']

In [4]:
print dir(Foo1)
['__doc__', '__module__']

参考:[1] stackoverflow: what is the difference between old style and new style classes in Python?

         [2] The Inside Story on New-style Classes

posted on 2015-09-02 22:49  conard  阅读(1170)  评论(0编辑  收藏  举报