Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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; 'essentially': 0.04; 'interpreter': 0.05; '21,': 0.07; 'differently': 0.07; 'sys': 0.07; '(currently': 0.09; '__name__': 0.09; 'abstraction': 0.09; 'bug.': 0.09; 'claimed': 0.09; 'exec': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runs': 0.10; 'def': 0.12; 'jan': 0.12; "wouldn't": 0.14; '6:56': 0.16; 'agreed,': 0.16; 'assignments.': 0.16; 'buggy': 0.16; 'code),': 0.16; 'debugger.': 0.16; 'does,': 0.16; 'idle.': 0.16; 'indirectly': 0.16; 'interactive,': 0.16; 'leaks': 0.16; 'modules,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'bit': 0.19; 'possible,': 0.19; 'stack': 0.19; '(the': 0.22; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'case.': 0.24; 'instance,': 0.24; 'mon,': 0.24; 'looks': 0.24; 'options': 0.25; 'least': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'url:bugs': 0.29; 'am,': 0.29; 'mode': 0.30; 'subject:please': 0.30; 'code': 0.31; '>>>>': 0.31; 'inspect': 0.31; 'subject:users': 0.31; 'url:python': 0.33; 'running': 0.33; 'actual': 0.34; 'could': 0.34; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'consistent': 0.36; 'idle': 0.36; 'limitations': 0.36; 'sequence': 0.36; 'url:org': 0.36; 'should': 0.36; 'implement': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'does': 0.39; 'environment.': 0.39; 'received:71': 0.39; 'reported': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'break': 0.61; 'show': 0.63; 'such': 0.63; 'different': 0.65; 'details': 0.65; 'between': 0.67; 'close': 0.67; 'subject': 0.69; 'acts': 0.74; 'jul': 0.74; '7:00': 0.84; 'difference.': 0.84; 'ii.': 0.84; 'received:fios.verizon.net': 0.84; 'subject:read': 0.84; 'viable': 0.84; '(ii)': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Idle's Shell: prompts and indents (was ...) Idle users please read Date: Mon, 21 Jul 2014 14:30:30 -0400 References: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: 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: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405967455 news.xs4all.nl 2937 [2001:888:2000:d::a6]:40272 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74941 On 7/21/2014 6:56 AM, Chris Angelico wrote: > On Mon, Jul 21, 2014 at 7:00 PM, Terry Reedy wrote: >> In general, Idle should execute user code the same way that the interpreter >> does, subject to the limitations of the different execution environment. > > Agreed, but I think the setting of prompts is a "different execution > environment" case. It's a fundamental difference between batch mode > and interactive, and Idle uses batch mode to implement interactive > mode. So something like: > >>>> sys.ps1="Python> " > "Setting sys.ps1 has no effect in Idle; see the Options menu." >>>> > > It might not be possible, but if it is, it wouldn't break any actual > viable use-cases. It would be a lot of work for close to 0 gain. It could not work consistent without special-casing sys assignments. Consider >>> prompt1 = 'Me>' >>> setps1 = sys.ps1 >>> setps1(prompt1) ;-(. Idle cannot exactly imitate the interactive interpreter (II) because it does not execute code in exactly the same way. For instance, http://bugs.python.org/issue21997 reported that fact that the sequence >>>def dodebug(): pdb.set_trace() >>>dodebug() behaves differently in Idle and II. Not knowing the details of Idle (currently only available in the code), the OP claimed that this is an Idle bug. It turns out that running dodebug indirectly >>> def run_code(code): exec(code, globals()) >>> run('dodebug()') *in the II* behaves like Idle. The above is essentially how Idle runs code. (The difference is that it substitutes a custom namespace designed to look like the globals() of a main modules, include having __name__ == '__main__'.) Well, at least I know now, so I know how to review claims that Idle is buggy when it acts a bit differently than the II. The exec abstraction has a few tiny leaks if one looks hard enough, such as with the debugger. Using inspect to look at the frame stack would also show a difference. -- Terry Jan Reedy