Deleting objects

Michael Hudson mwh at python.net
Thu Apr 22 10:23:52 EDT 2004


tkpmep at hotmail.com (Thomas Philips) writes:

[snip]

> Villain dies and executes its destructor (__del__). The game then
> ends. However, when I execute the program in IDLE, IT FINISHES BY
> EXECUTING THE DESTRUCTOR FOR BOTH HERO AND VILLAIN.

Err, __del__ isn't a destructor, it's a finalizer.  It's called by the
Python runtime when it has determined that the object is garbage,
which is usually immediately after the last reference to it is
dropped.

Cheers,
mwh

-- 
  Good? Bad? Strap him into the IETF-approved witch-dunking
  apparatus immediately!                        -- NTK now, 21/07/2000



More information about the Python-list mailing list