Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'falls': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; '__del__': 0.16; 'called.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'heap': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'received:google.com': 0.35; 'object,': 0.36; 'method': 0.36; 'so,': 0.37; 'pm,': 0.38; 'does': 0.39; 'delete': 0.39; 'skip:p 20': 0.39; 'called': 0.40; "you're": 0.61; 'hear': 0.63; 'smith': 0.68; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=PD7FyD2Wy7NHNhdIhrrMXPlYgc25vXuWHykIcHLwIGQ=; b=dBaNx59U3LSu0RCqrK03RioqEbBaYwWPcA2UgPP/oDDTBozOJiIpRozvnXzH2UFygF GZy09dojSxoK6EzjsrBM79+/BrjGWj4VdUkswQnnNM7N0Ak0+rNMHte8wXA0qPWkUk8y vqADmRKp40jHqIZdnywfX0SUrHNCJQMENcjDYR5WsvpvERQeEfv268HKZ9Wwf52udh+R /Hs7OMNfb+T0F/QUqzkFcpAElsajn8ezeH9gUztBIjsPedd+mZUzG9kYee0kmaJKnkBR Qd/ETh0spvJ3mM9A7kSn6V3/h4MdNnOXUCqpMmamFPC1SebXiDOyIJkHKikriSP+ztEq c5eQ== MIME-Version: 1.0 X-Received: by 10.68.108.194 with SMTP id hm2mr35684186pbb.22.1391406593164; Sun, 02 Feb 2014 21:49:53 -0800 (PST) In-Reply-To: References: <858utviwgs.fsf@benfinney.id.au> <52EC3C40.7080402@stoneleaf.us> <52ec84bc$0$29972$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 3 Feb 2014 16:49:52 +1100 Subject: Re: __init__ is the initialiser From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391406602 news.xs4all.nl 2832 [2001:888:2000:d::a6]:36437 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65321 On Mon, Feb 3, 2014 at 4:12 PM, Roy Smith wrote: > So, what you're saying is when I delete an object, __del__() has both > been called and not been called? >>> class Schrodinger: def __init__(self): print("Init!") >>> print(Schrodinger()) Init! <__main__.Schrodinger object at 0x02B52570> At this point, __del__ has indeed both been called and not been called. However, observing its state will force it to collapse: >>> class Schrodinger: def __init__(self): print("Init!") def __del__(self): print("Del!") >>> print(Schrodinger()) Init! <__main__.Schrodinger object at 0x02B52830> Del! If an object falls off the heap and there's no __del__ method to hear it, does it call __del__? ChrisA