Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.04; 'terry': 0.07; '3.x': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'pm,': 0.11; '>>>': 0.12; 'version,': 0.14; 'wrote:': 0.14; 'beginning.': 0.16; 'keith': 0.16; 'reedy': 0.16; 'reload': 0.16; 'simulate': 0.16; 'subject:changes': 0.16; 'jan': 0.22; 'code': 0.22; 'header:In- Reply-To:1': 0.22; 'away.': 0.23; 'subject:code': 0.23; 'version': 0.25; 'pass': 0.27; 'testing': 0.28; 'subject:?': 0.29; 'class': 0.29; 'changes': 0.29; 'to:addr:python-list': 0.32; 'generally': 0.33; 'using': 0.34; 'header:X-Complaints-To:1': 0.34; 'header :User-Agent:1': 0.35; 'instances': 0.35; 'module.': 0.35; 'references': 0.38; 'but': 0.38; 'received:org': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'header:Received:5': 0.40; 'best': 0.60; 'restart': 0.84; 'subject:alternatives': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Testing changes to Python code on the fly: reload() + alternatives? Date: Tue, 12 Apr 2011 18:49:27 -0400 References: <31f668e3-639f-4d4d-b406-0e3342d115a8@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: <31f668e3-639f-4d4d-b406-0e3342d115a8@glegroupsg2000goo.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302648583 news.xs4all.nl 41103 [::ffff:82.94.164.166]:34516 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3094 On 4/12/2011 3:26 PM, Keith wrote: > 1) Is it possible to reload a class using the reload() method? Yes, but instances of the old version will remain instances of the old version, which will not go away until all its instances and other references go away. So reload is deceptive, which is why it was semi-hidden away in 3.x in the inspect module. >>> class C: pass >>> c = C() >>> class C: pass # simulate reload >>> c2 = C() >>> id(c.__class__) 16018776 >>> id(c2.__class__) 16039320 > 2) More generally though, what is the best way to go about testing changes to code Restart from the beginning. -- Terry Jan Reedy