object lifecycle in the previous exampleswe define class (template)use that class to create an instance of that class (object)and then use the instance when the program finishesall of the variables are discarded usuallywe don' think much about the creation and destruction of variablesbut often as our objects become more complexwe need to take some action within the object to set things up as the object is constructed and possibly clean things up as the object is discarded if we want our object to be aware of these moments of construction and destructionwe add specially named methods to our objectclass partyanimalx def __init__(self)print(' am constructed'def party(selfself self print('so far',self xdef __del__(self)print(' am destructed'self xan partyanimal(an party(an party(an print('an contains',ancodewhen this program executesit produces the following outputi am constructed so far so far am destructed an contains as python constructs our objectit calls our __init__ method to give us chance to set up some default or initial values for the object when python encounters the linean it actually "throws our object awayso it can reuse the an variable to store the value just at the moment when our an object is being "destroyedour destructor code (__del__is called we cannot stop our variable from being destroyedbut we can do any necessary cleanup right before our object no longer exists