py06_03: __ understand the method of del__

In contrast with the init del

 

 

 

class Cat:   # define tired 
    '' '   the __init__: The method is designed to define a class, a method which has the property. '' ' 
    DEF  the __init__ (Self, name, Age):
         Print ( ' This is a method of initializing a ' ) 
        the self.name = name 
        self.age = Age 

    DEF  the __del__ (Self):
         Print ( ' % S gone, gone before performs last operation ' % the self.name) 


    DEF EAT (Self):
         Print ( ' % S ' % the self.name) 



#When you create an object, it automatically calls the initialization method __init__. That is, as long as the generated object initialization is performed 100% 


tom = Cat ( ' God ' , 16)   # Note that the number of variable initialization, you need to create objects time how many write 


tom.eat () 
del tom   # previous accounting deleted the effect of deleting 

Print ( ' - ' * 50)

 

Guess you like

Origin www.cnblogs.com/yeyu1314/p/12550141.html