Deleting objects

Mark McEahern mark at
Thu Jan 15 05:01:46 CET 2004

On Wed, 2004-01-14 at 17:23, user at domain.invalid wrote:
> 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[0]
> Python says:
>   object doesn't support item deletion

It'd be helpful if you supplied the code in question.  Then again, we
wouldn't be able to let our imagination wander with what puff might
mean.  <wink>

Anyway, is this the sort of thing you're talking about?

#!/usr/bin/env python

class Foo:

    def __init__(self): = []

    def __str__(self):
        return '<Foo><bar>%s</bar></Foo>' % (str(,)

l = range(10)

foo = Foo()
print 'foo = %s' % (str(foo),)
print 'l = %s' % (l,)


// m

More information about the Python-list mailing list