#_ *_coding:utf-8 _*_#: The difference between a classic class and a new class # Parent class Class father (object): def __init__ (self): self. fname = ' fffffff ' print ' father.__init__ ' def func (self): print ' FUNCFURNC ' def bar (self): print ' Barbarbar ' def test (self): #再定义一个方法 print ' 11111 ' print ' testtest ' #子类继承父类, That means the Son class can get the Father class method Class son (Father): def __init__ (self): self. sname = ' Sonsonson ' print ' son.__init__ ' fatHer.__init__ (self) #调用父类的构造函数, this is the first form, this way can not inherit object Super (Son, self). __init__ () #调用父类的构造函数, which is the second form that must inherit Object def yes (self): print ' Barbarbar ' def test ( Self): print ' aaaaaaaa ' # Override the parent class's Test method # to instantiate the subclass, trying to access the method S1 = son () #实例化子类s1 in the parent class. Bar () #成功访问父类的方法s1. Test () #访问重写后的方法 ' ' Other instructions: If you inherit object then it is the new class, recommend the use of modern class if there is no inheritance object that is the classic class difference: Classic class , the use of depth-first traversal of the parent class in multiple inheritance, and a new C3 algorithm to traverse the parent class when multiple inheritance
This article is from the "Fa&it-Q Group: 223843163" blog, please be sure to keep this source http://freshair.blog.51cto.com/8272891/1874428
Python's brief talk about new and old class (or classic Class)