First, you first define a simple person class
1 class Person : 2 Head = 13 ear = 24 5 def Eat (self):6 Print (' eat ')
In terms of what is a class, the definition class, the class object, the instantiation of the class, the initialization of the class is a very confusing concept for beginners.
Sometimes, it is easier to understand the more familiar concepts in our life than the new points of knowledge.
First imagine, what is human, animal, plant, bird?
Human, Xiao Ming (a specific person)
Animal class, Lion King Leo (specific one animal)
Plant type, peony (specific flower)
Bird, Woodpecker (specific one bird)
Object
In real life, looking for an object is to find a living person.
So, the code, 1-6, defines a class named person.
Notice that the name is person,
Class person, which is defined
P1 = person ()
After executing the statement
P1 is an object of the person class, or it can be called an instance, and the concept of an object and an instance can be equated.
Execute person (), which is the instantiation of the class
The instantiation of a class can be understood as the whole process of creating an object by a class, which is done by the Python interpreter.
Instantiate this process execution ends and return the address of the instance to P1
Examples, literal understanding, real examples of existence, the key is the existence
Defining a class is a clear concept, what you can do and what you can't do. Just conceptually.
An instance (object) is created, and the instance is then called to the method in the class.
Python 16th-day class instantiation