Python's object base class __del__ method __python

Source: Internet
Author: User

Python's object base class __del__ method


This method of Python is a destructor that executes when an instance is destroyed, destroys the memory associated with the instance, methods, attributes, and so on. Also, if the base class specifies a particular property or other method, the subclass also needs to be explicitly specified.

In general, you do not need to overwrite this method.

Python3.4 Documents:

Object. __del__ (self)

Called when the instance are about to be destroyed. This is also called a destructor. If a base class has a __del__ () method, the derived class ' s __del__ () method, if any, must explicitly call it to ensure PR Oper deletion of the base class part of the instance. The It is possible (though does recommended!) for the __del__ () method to postpone destruction of the instance by CRE Ating a new reference to it. It may then to called at a later time when this new reference is deleted. It is not guaranteed which __del__ () methods are called for objects this still exist when the interpreter exits

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.