. Classic class. New class. Depth first. Breadth First
First, the classic class is a noun in Python 2.x, Python 2.x default is the classic class, only the display inherits the object is the new class; in python3.x, the new class is the default.
Classic class explanation
Object is the "mother of all Classes". And in python2.x to write the object is the new class, so obviously nothing is written is the classic class, in fact, if you do not specify a parent class, or if the subclass of the basic class does not have a parent class, you create a classic class. Let's look at an example:
1 # !/usr/bin/python2 2 # -*-coding:utf-8-*- 3 4 class Myobjecttype: 5 ' define Myobjecttype Classic class ' 6 Class_suite
View CodeA new type of explanation
From the above, the class inherits the base class of object, which is the new class. However, in python3.x, the default is the new class, and the classic class is removed without having to display the inherited object.
1 #!/usr/bin/python32 #-*-coding:utf-8-*-3 4 classMyobjecttype (object):5 'define Myobjecttype New class'6 Class_suite7 8 classMynewobjecttype ():9 'define Myobjecttype New class'TenClass_suite
View Code
When it comes to classical and modern classes, it is important to mention the two nouns of depth first and breadth first.
The new-type MRO algorithm uses C3 algorithm breadth-first search, while the classic-class MRO algorithm uses depth-first search.
Depth first
1 #!/usr/bin/python22 #-*-coding:utf-8-*-3 4 classA:5 Pass6 classB:7 Pass8 classC (B):9 PassTen classD (c,a): One Pass
View Code
The order of execution is: D->c->b,->a
Breadth First
1 #!/usr/bin/python32 #-*-coding:utf-8-*-3 4 classA (object):5 Pass6 classB (object):7 Pass8 classC (object):9 PassTen classD (a,b,c): One Pass
View Code
The order of execution is: D->a->b->c->object
Python---Object-oriented programming-2