Deleting objects

user at domain.invalid user at domain.invalid
Thu Jan 15 00:23:40 CET 2004


Say I have an object (foo), that contains an
array (bar) of references to other objects.

Now I want to puff some of the objects from the
array so that I remove the array element, and
destroy the oject.

but when I do:

del foo.bar[0]

Python says:
  object doesn't support item deletion

So do I need to define __del__?  And what would I
put there?

What if I wanted to remove the array element
but still have the object exist?

What happens if I succeed in destroying an object
that other objects still think they are referencing?

Thanks,

Toby




More information about the Python-list mailing list