1. Multi-Objective assignment
2. Multi-objective assignment and shared reference
There's no problem with non-mutable objects, but for mutable objects, there's a problem here.
The above example AB is immutable, so when B changes, the object that B points to has been re-created.
Because the list is mutable, AB points together to the same list, so when B changes, a also changes
3. Enhanced Assignment
Enhanced assignment is the use of +=,>= and other operators to assign values, here are two examples
4. Enhanced assignment and shared references
The following example is, the enhanced assignment uses + =, here the enhancement assignment implies in the original place to modify the meaning, everybody needs to notice
The above example can be seen, if you use the + expression, just an object modification, but using + =, two list simultaneously modified
5. Variable naming rules
1) Syntax: underline or character + any number of letters, numbers, or underscores
2) Case-sensitive, a and a are two different variables
3) disable reserved words (specific query Python manual)
Note: The naming convention extends to the name of the filename, and if the file name does not conform to the variable naming rules, an error occurs when importing
Right here, thank you.
------------------------------------------------------------------
Click to jump 0 basic python-Catalogue
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 Basic python-10.2 Multi-objective assignment and variable naming rules