[Tutor] How to delete a class instance
Kent Johnson
kent37 at tds.net
Wed Mar 16 12:06:14 CET 2005
Shitiz Bansal wrote:
> Hi,
> How do i delete a class instance in a function running
> within itself?
> All the instances of the class are stored in a list,
> and they need to be deleted after executing their
> function.
> However since the list is dynamic, there is no way to
> know the exact position of the instance within the
> list.
You have to do this from the caller, in code that has access to the list. There is no general way
for an object to find out how it is being referenced in external code. Can you show some of the code
that creates and uses the list? Does the code that calls the class know where the class is in the list?
Is this the linked list you asked about before that is modified from two threads?
>
> I tried del self to no avail.
del self just removes the link between the name 'self' and the object it references.
Kent
More information about the Tutor
mailing list