Python has a lot of special methods like __del__ (self), some such as __gt__ (), __le__ () and so on can be guessed from the name of its approximate function, but some can not be so random guessing (of course, it is possible that I alone will do), For example, __del__ () and Del, which I used to think when Del is an object, __del__ () will be called, however, after a few written tests have failed, I began to examine these finer places ^_^!
Gossip less, get to the point!
We know del is deleting an object, in fact, it should be to make the object's reference count minus one. Note, however, that __del__ () is not called every time it is called, because __del__ () is called when the reference count of the object is reduced to 0 o'clock, as the example permits:
>>> class C: def __del__ (self): print ("I ' m Vanishing ...") >>> C = C () >>> B = C # Note , at this point the reference count for C () is 2>>> del b>>> # Look, what output is not, the description __del__ () does not call >>> del CI ' m vanishing ... # The reference count is reduced to 0 before it is called >>>