Learning DAY10 python (instance variables and class variables)

---- static properties instance variables (each object having attributes described) 
for class ---- dynamic properties of 

class variables: not any of the methods in the class instance variable is not defined. (Similar to C ++ static variables in your class in memory) 
function: to save money 
if: When the class and instance variables of the same name, the instance of the object that calls the instance variable to find itself -> after seeking class variables, i.e. to output instance and class variables not output; if not, then the output variable class 
objects: one object class to modify variables, to add the substance is a variable in the memory of the object, but does not affect the value of such variables, this when calling other objects class variables, class variables is still the original 
class name: the class name as the scope, modify the class variables, this time will affect calls to other objects (of course, when the class to modify variables through the object, and value does not affect the value affects only the object's class variables) 
but if the class variable is a list, then modified by the object or class variables directly affect the class name changes will be! 

Increased instance variables :( object instance variable name = True) Note: At this time a new instance variable to add only attributed to the object of all other objects instantiated do not enjoy this variable 
to delete the instance variables :( del instance variable name) from To remove the memory object instance variables

 

Guess you like

Origin www.cnblogs.com/god-for-speed/p/11362382.html