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


Groups > comp.lang.python > #106890

Re: REMOVE ME

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From John Pote <johnhpote@o2.co.uk>
Newsgroups comp.lang.python
Subject Re: REMOVE ME
Date Mon, 11 Apr 2016 23:44:25 +0100
Lines 37
Message-ID <mailman.36.1460414670.15650.python-list@python.org> (permalink)
References <CALuqfDDNQ0N6xQXEKurzK1v0eVfU7jr6=-uvLT1zeGcf3vgexQ@mail.gmail.com> <CAPTjJmrdgBsSWUkNi+H8Tm8eqHA53pxVM-FP8ChqsxRNCeRNGA@mail.gmail.com> <570C28C9.3090103@o2.co.uk>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de cial6as3fS06oQ+3OixsigX7bJyxiYPtq1x+hSbOO0zA==
Return-Path <johnhpote@o2.co.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.041
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'attribute.': 0.09; 'garbage': 0.09; 'instance.': 0.09; 'python': 0.10; 'def': 0.13; '2016': 0.16; 'presume': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'released.': 0.16; 'sure.': 0.16; 'wizard': 0.16; 'wrote:': 0.16; 'memory': 0.17; 'attribute': 0.18; 'email addr:gmail.com&gt;': 0.18; 'prevent': 0.20; 'seems': 0.23; 'references': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'external': 0.27; 'right.': 0.27; 'wonder': 0.27; 'looks': 0.29; 'guarantees': 0.29; 'objects': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.30; 'class.': 0.30; 'skip:_ 10': 0.32; 'getting': 0.33; 'class': 0.33; 'url:python': 0.33; 'url:listinfo': 0.34; 'list': 0.34; 'could': 0.35; 'instance': 0.35; 'quite': 0.35; 'something': 0.35; 'but': 0.36; 'list,': 0.36; 'there': 0.36; 'url:org': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'things': 0.38; 'itself': 0.38; 'mean': 0.38; 'sure': 0.39; 'received:192': 0.39; 'rather': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'still': 0.40; 'called': 0.40; 'your': 0.60; 'john': 0.61; 'skip:u 10': 0.61; 'received:uk': 0.61; 'bring': 0.62; 'back': 0.62; 'charset:windows-1252': 0.62; 'life': 0.67; 'reply': 0.68; 'hand': 0.82; 'chrisa': 0.84; 'ghost': 0.84; 'technique': 0.93; 'mystery': 0.95
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Thunderbird/38.7.1
In-Reply-To <CAPTjJmrdgBsSWUkNi+H8Tm8eqHA53pxVM-FP8ChqsxRNCeRNGA@mail.gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <570C28C9.3090103@o2.co.uk>
X-Mailman-Original-References <CALuqfDDNQ0N6xQXEKurzK1v0eVfU7jr6=-uvLT1zeGcf3vgexQ@mail.gmail.com> <CAPTjJmrdgBsSWUkNi+H8Tm8eqHA53pxVM-FP8ChqsxRNCeRNGA@mail.gmail.com>
Xref csiph.com comp.lang.python:106890

Show key headers only | View raw


On 10/04/2016 04:52, Chris Angelico wrote:
> 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
I'm not quite sure how tongue in cheek ChrisA's reply and the Thing 
class was but it did make me think and wonder if my understanding of 
Python lore was quite right. To my mind it looks like a Zombie or even 
Revenant class.

If all external references to an instance of Thing are deleted there is 
still the reference from the class list 'things []'. In which case will 
not this prevent the instance from being garbage collected and __del__() 
never called on the dead instance and its memory never released. But a 
memory dump could reveal the ghost of the instance. On the other hand a 
code wizard with the right lore could resurect the instance by getting 
the reference to it and bring it back to life -
     revenant = Thing.things[x]

But then I notice 'things' is used as an instance attribute rather than 
a class attribute. All seems to be shrouded in a web of mystery

Regards,
John

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


Thread

Re: REMOVE ME John Pote <johnhpote@o2.co.uk> - 2016-04-11 23:44 +0100
  Re: REMOVE ME Steven D'Aprano <steve@pearwood.info> - 2016-04-12 09:10 +1000
    Re: REMOVE ME Chris Angelico <rosuav@gmail.com> - 2016-04-12 10:44 +1000

csiph-web