Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python': 0.09; 'received :mail-vc0-f174.google.com': 0.09; 'sep': 0.09; 'subject:()': 0.09; '__del__': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'it".': 0.16; 'none).': 0.16; 'sentinel': 0.16; 'wrote:': 0.17; 'tries': 0.17; 'object.': 0.22; 'references': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'crash': 0.29; "d'aprano": 0.29; 'received:209.85.220.174': 0.29; 'steven': 0.29; 'objects': 0.29; 'code': 0.31; 'could': 0.32; 'to:addr :python-list': 0.33; 'times.': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'method': 0.36; 'does': 0.37; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'become': 0.65; "'with'": 0.84; 'construct': 0.84; 'subject:skip:g 10': 0.84; 'viable': 0.84; 'remember,': 0.93 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:to :content-type; bh=p2znVNGh07cLwy6B8t5X6Mi8/HJyWbeY74qPs1yBhpQ=; b=UiD9wmRTJFvZTZ9tnFSpQ+1ezpDpSL6sJ+yF2/hMv+2bXHj8gI85HWkO04LXuUzf+7 qTRGMcU0OPjGF7Ts7P0u9GWcsuG1gzcNOZDa3UVWalUCvLrQOWDIywkWCsLjJt8NMERK ICXlHR5yjhq5VVRmFZTpEgRy/gPBpFveUQRQ9q11OD8O6bcNjsFQm2hOpuNMhBhK+waO J+Bs9MzbsLPID3cF+46bb9IPt1I0GN/Ch+2JUcoe1buHd3xZOCetAUWpQt0yDm6cBv+K Ms0lNu79I6t8tMSZ5oivriXs+7s0nWF6jCxqJBzvIgbH6kW+vICJA5Kez8PYuBICHsN8 WzSQ== MIME-Version: 1.0 In-Reply-To: <505730ad$0$29981$c3e8da3$5496439d@news.astraweb.com> References: <52847c35-388c-4758-b72d-1d1859b788a3@googlegroups.com> <8370412f-5176-45ff-87eb-72cbca5149d5@googlegroups.com> <5055a1a6$0$29981$c3e8da3$5496439d@news.astraweb.com> <4f9d9a0b-539a-4b6a-af3e-b02d1f4006ee@googlegroups.com> <505730ad$0$29981$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 18 Sep 2012 02:09:25 +1000 Subject: Re: gc.get_objects() From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347898166 news.xs4all.nl 6950 [2001:888:2000:d::a6]:55285 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29382 On Tue, Sep 18, 2012 at 12:16 AM, Steven D'Aprano wrote: > The __del__ method does not delete an object. Remember, objects are only > deleted when there are no references to it. Otherwise you could have some > code that tries to use a deleted object, and you would get a system crash > or BSOD. There is a conceptually viable alternative: destroy an object immediately and force all references to it to become some sentinel value (eg None). Python currently doesn't have this, but it would be rather convenient at times. Could be part of a construct like 'with' to say "make this, use it, and then dispose of it". ChrisA