Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Vincent Vande Vyvre Newsgroups: comp.lang.python Subject: Re: Persist objects in a LIST Date: Sat, 14 Nov 2015 17:33:59 +0100 Lines: 30 Message-ID: References: <0cb1bcda-54d5-4cc7-bd23-f86f7f10ee28@googlegroups.com> <15f9fdeb-f4b4-4404-bccb-2e67a26035ed@googlegroups.com> Reply-To: vincent.vandevyvre@oqapy.eu Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de x2GC5qBEJlBqgD0EGYmFygy5jtmyAt5aO+m5PYpoCXwQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.048 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'empty,': 0.09; 'from:name:vincent vande vyvre': 0.16; 'received:195.130': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'received:telenet- ops.be': 0.16; '\xe9crit': 0.16; 'solution.': 0.18; '>>>': 0.20; '2015': 0.20; 'rid': 0.22; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'dictionary': 0.29; 'second,': 0.29; 'creating': 0.30; 'received:be': 0.30; 'nov': 0.35; 'replace': 0.35; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'john': 0.61; 'charset:windows-1252': 0.62; 'binding': 0.66; 'header:Reply- To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'dennis': 0.91 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98815 Le 14/11/2015 16:39, Dennis Lee Bieber a écrit : > On Sat, 14 Nov 2015 07:02:41 -0800 (PST), John Zhao > declaimed the following: > >> I found a solution. replace bDict.clear() with bDict = {} >> > Which is creating a second, empty, dictionary and binding the name > "bDict" to that new one. > > If all you want is to get rid of the name > > del bDict > > should suffice. Not exactly. >>> l = [] >>> d = {'key': 'val'} >>> l.append(d) >>> l [{'key': 'val'}] >>> del d >>> l [{'key': 'val'}] >>> del l[0] >>> l [] >>> Vince