Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106773

Re: REMOVE ME

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: REMOVE ME
Date 2016-04-10 13:52 +1000
Message-ID <mailman.2.1460260336.424.python-list@python.org> (permalink)
References <CALuqfDDNQ0N6xQXEKurzK1v0eVfU7jr6=-uvLT1zeGcf3vgexQ@mail.gmail.com> <CAPTjJmrdgBsSWUkNi+H8Tm8eqHA53pxVM-FP8ChqsxRNCeRNGA@mail.gmail.com>

Show all headers | View raw


On Sun, Apr 10, 2016 at 1:46 PM, fan nie <niefan68@gmail.com> wrote:
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Sure. I presume you mean something like this:

class Thing:
    things = []
    def __init__(self):
        self.things.append(self)
    def __del__(self):
        # Remove me when I'm dead
        self.things.remove(self)

This ingenious technique guarantees that you never have dead objects
in your list, by having each object remove itself when it dies.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: REMOVE ME Chris Angelico <rosuav@gmail.com> - 2016-04-10 13:52 +1000

csiph-web