self destruction :)
Steve Holden
sholden at holdenweb.com
Fri Jun 28 09:51:29 EDT 2002
"Guyon Morée" <gumuz at looze.net> wrote ...
> > x = [a, b, c]
> >
> > and you want to remove b from the list?
> >
> > Just say "del x[1]".
>
>
> yep this is actually what i mean, but the problem is is that this action
> should come from the object within the list. this is object 'knows' when
> it's done, the list doesn't
>
> see my problem?
>
Indeed. If your objects don't "know" which list they are being held on, or
what element they are in that list then you have a problem: objects in
Python can't tell which variables or other items are bound (refer) to them
It's even trickier with a list, because you can't just keep the index as an
object attribute: ince you delete one list element, all indexes above it
would need to be reduced by one.
Perhaps, rather than assuming a particular type of answer is required to
your problem, you could just step back a little and describe in application
terms what it is you need to do. c.l.py contains enough inventive and gifted
programmers you are almost certain to get a workable solution to the real
problem.
regards
----------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------
More information about the Python-list
mailing list