Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Reason for not allowing import twice but allowing reload() Date: Tue, 1 Mar 2016 02:04:35 -0500 Lines: 31 Message-ID: References: <645cdd46-d4a4-49b3-a0d8-848608d70d73@googlegroups.com> <5c8e3283-2013-4f68-87b8-6311ccee64a3@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de jnpPv9DUmUrCfnfFUvmZRgxC4g4lGRD+O2q2PXlRMSPA== 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; "'python": 0.07; 'restarting': 0.07; 'terminated': 0.07; 'beginners': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:()': 0.09; 'python': 0.10; 'jan': 0.11; 'subject:not': 0.11; 'interpreter': 0.15; 'is).': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:import': 0.16; "up'": 0.16; 'wrote:': 0.16; '(in': 0.18; 'shell': 0.18; 'runs': 0.18; 'doc': 0.22; 'python"': 0.22; 'trying': 0.22; 'am,': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'command': 0.26; 'header:X-Complaints-To:1': 0.26; 'earlier': 0.27; 'equivalent': 0.27; 'followed': 0.27; 'separate': 0.27; 'restart': 0.29; 'code': 0.30; 'maybe': 0.33; 'run': 0.33; 'idle': 0.33; 'impression': 0.33; 'file': 0.34; 'add': 0.34; 'done': 0.35; 'something': 0.35; 'should': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'one,': 0.37; 'means': 0.39; 'whatever': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'email addr:gmail.com': 0.62; 'received:96': 0.63; 'more': 0.63; 'started.': 0.66; 'prompt': 0.79; 'killing': 0.84; 'loose': 0.84; 'received:fios.verizon.net': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-96-227-207-81.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <5c8e3283-2013-4f68-87b8-6311ccee64a3@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 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:103779 On 2/29/2016 8:22 AM, alien2utoo@gmail.com wrote: > Hello Rustom, > > F5 in Idle restarts the Python interpreter (that's what my impression is). More exactly, IDLE runs user code in a separate process from the one that runs the IDLE gui. Restarting means that the existing user process is terminated and a new one started. This is easier than trying to 'clean up' the existing process. If you start python with '> python' in a terminal, then restarting the interactive interpreter means '>>> quit' at the interactive prompt followed by "> python" in the console. You do the equivalent in IDLE Shell with 'control-F6' or 'Shell -> Restart Shell. F5 when editing path/file.py replaces the command 'python' with 'cd path' followed by 'python -i file.py' Maybe I should add something to the IDLE doc for people familiar with using python in a console. (Most beginners are not.) > Whatever you have done earlier at Idle prompt (in Idle session) > before F5 is gone after F5. Yes, the same as if you quit(). A change I would like to make sometime is to have F5 run the file is a new user process without killing the old one, so one does not loose work done in Shell. -- Terry Jan Reedy