Summary: Functional application Scenarios –> separate and no shared data between functions.
Object-oriented three major features
the three major characteristics of object-oriented are: encapsulation, inheritance and polymorphism.
first, the package
encapsulation, as the name implies, encapsulates the content somewhere and then calls the content that is encapsulated somewhere. Small series recommend you add this group: 103456743 This group of thousands of people! All the problems we meet will be communicated inside! and free to share 0 basic Primer Material Web Development crawler data set! is a very good place to study and exchange! Also has the programmer big God to everybody eagerly answers various questions! was soon full. Want to enter quickly Oh! A variety of PDFs waiting for you to download! All are free of charge Oh! Just to help everyone get started quickly, so small in the group waiting for you to come together to exchange learning!
therefore, when using object-oriented encapsulation features, you need:
- Encapsulate content somewhere
- To invoke the encapsulated content from somewhere
First step: encapsulate the content somewhere
Exercise two : Game Life Program
D1=dog (' Fat family's little Skinny Dog ')d1.eat ()
so the question comes again, how to inherit?
- Whether multiple classes can be inherited
- If you have inherited multiple classes that have the same function in each class, then that one will be used?
1. Python classes can inherit multiple classes, and Java and C # can inherit only one class2, Python class if the inheritance of more than one class, then its way to find two ways, namely: depth priority and Breadth first
Advanced article
As can be seen from the code above, "Ordinary fields need to access the" static field through the class access, in the use can be seen in the normal field and static field attribution is different. Its content is stored in a similar way as:
2. Two ways to define attributesThere are two ways to define a property:
- Adorners: Applying adorners on methods
- Static fields are: Static fields that define values as property objects in a class
Adorner mode: Apply @property adorner to ordinary method of classwe know that the classes in Python have classic and modern classes, and the properties of the new class are richer than those of the classic class. (If the class is following object, then the class is a modern Class)Classic class with a @property adorner (as in the previous step)
6. __dict__all members in a class or objectas we know above, the ordinary fields of the class belong to the object, and the static fields and methods in the class belong to the class, namely:
Python Object-Oriented tutorials