Python advanced programming, python Advanced Programming
1. =, is usage
Summary
· Is to compare whether two references point to the same object (reference comparison ).
· = Is to compare whether two objects are equal.
2. Deep copy and light Copy 1. Light copy
A shallow copy is a top-level copy of an object.
The general understanding is that the reference is copied and the content is not copied.
2. Deep copy
Deep copy is a copy (recursion) of all layers of an object)
Further Understanding 3. Other methods of copying
The copy of an immutable type is different from that of a mutable type.
· A multipart expression can assign values to a sequence.
· The dictionary copy method can copy a dictionary.
· Some built-in functions can generate a copy (list)
· Copy function in the copy Module
3. Add the getter and setter methods to the property property1. use the property to upgrade the getter and setter methods.
Running result:
Running result: 3. Replace the getter and setter methods with property.
@ Property becomes an attribute function. You can perform necessary checks when assigning values to attributes, and ensure that the Code is clear and short. It has two main functions:
· Convert the method to read-only
· Implement a new attribute setting and reading Method to Determine the Boundary
Running result:
Running result:
If you have any questions during the learning process or want to obtain learning resources, join the learning exchange group.
626062078. Let's learn Python together!