Python is divided into classic and modern classes:
Classic class:
Class A ():
Pass
New class:
Class A (object):
Pass
So the difference between a classic class and a new class is that when declaring a class, the new class needs to be prefixed with the object keyword.
The difference between classic and modern classes in Python:
The difference is mainly embodied in inheritance:
Python classes can inherit multiple classes, and Java and C # can inherit only one class
If a Python class inherits more than one class, there are two ways to find the method
When a class is a classic class, multiple inheritance cases are searched in the depth-first way
When a class is a new class, in multiple inheritance cases, the breadth-first method is found
The simple point is: The Classic class is a portrait search, the new class is landscape search
1 Classic class:2 classLife ():3 defdaily (self):4 Print "Multiply"5 6 classAnimal (Life):7 defdaily (self):8 Print "Eat"9 Print "Drink"Ten Print "Pull" One Print "Isaac" A - classPuru (Life): - def __init__(self): the Pass - - classCat (puru,animal): - def __init__(self): + Print "Meow Meow" - +A =Cat () A a.daily () at - - the execution results are: - - Meow Meow - Multiply in - New class: to classLife (object): + defdaily (self): - Print "Multiply" the * classAnimal (Life): $ defdaily (self):Panax Notoginseng Print "Eat" - Print "Drink" the Print "Pull" + Print "Isaac" A the classPuru (Life): + def __init__(self): - Pass $ $ classCat (puru,animal): - def __init__(self): - Print "Meow Meow" the -A =Cat ()Wuyi a.daily () the - the execution results are: Wu - Meow Meow About Eat $ Drink - Pull -Sub
Breadth-First and depth-first in Python