The difference between a classic class and a new class
1, only the classic class in the Py2, the new class was added after the 2.2 version. How to differentiate, new class must inherit object after
There are only new classes in Py3. Write not write inheritance, are inherited by default object
2, the lookup order is not the same,
Classic class-depth first, is a way to go to the black
New class-Breadth first (that's less precise), by C3 algorithm, find out the order
Two, C3 algorithm
classA (object):PassclassB (A):PassclassC (B):PassclassD (object):PassclassE (d,c):PassclassF (object):PassclassG (F):PassclassH (c,g):PassclassFoo (e,h):Pass#print (E.__mro__) #查找E类的查找顺序#print (h.__mro__)"""L (Foo + L (E) + L (h)) L (e) = E,d,c,b,a,objectl (h) = H,c,b,a,g,f,objectfoo = (object) + (G,f,object) foo,e,d,h,c,b,a,g,f , Object"""Print(Foo.)__mro__)#(<class ' __main__. Foo ';, <class ' __main__. E ';#<class ' __main__. D ';, <class ' __main__. H ';, <class ' __main__. C ';#<class ' __main__. B ';, <class ' __main__. A ';, <class ' __main__. G ';#<class ' __main__. F ';, <class ' object ' >)
Find oral explanations
Gets the first header and the other table bits to compare
Do not exist then take away.
If present, then discards, and then gets the second table header again compared to the footer of the other table.
The difference between classic class and new class, C3 algorithm