How do I define a __del__ method for an object?

I was looking through Swaroop's tutorial, "A Byte of Python", on Python
objects,(http://www.python.g2swaroop.net/), and he mentions that you can
define a __del__ function to completely delete object instances.
However, when I try to define one in the attached script, not just one,
but all, of the defined objects disappear.

Can someone show me how to define a __del__ object that works on only
one object instance?

Stewart Midwinter wrote:
> I was looking through Swaroop's tutorial, "A Byte of Python", on Python
> objects,(http://www.python.g2swaroop.net/), and he mentions that you can
> define a __del__ function to completely delete object instances.
> However, when I try to define one in the attached script, not just one,
> but all, of the defined objects disappear.

?
> Can someone show me how to define a __del__ object that works on only
> one object instance?

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!