Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104133

Re: Application console for Tkinter program?

From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: Application console for Tkinter program?
Date 2016-03-06 07:12 -0500
Message-ID <mailman.239.1457266393.20602.python-list@python.org> (permalink)
References <nbe31k$c9$1@dont-email.me> <mailman.221.1457172954.20602.python-list@python.org> <nbegmb$b0q$1@dont-email.me> <mailman.232.1457212605.20602.python-list@python.org> <nbgsoa$upt$1@dont-email.me>

Show all headers | View raw


On 3/6/2016 4:23 AM, Christian Gollwitzer wrote:
> Am 05.03.16 um 22:16 schrieb Terry Reedy:
>> Not now. A console is a REPL + text display to read from and print to.
>> The actual IDLE REPL is PyShell.ModifiedInterpreter, which subclasses
>> stdlib code.InteractiveInterpreter.  Most of the additions are for
>> interacting with the subprocess that runs user code.  You should start
>> instead with the base class.
>>
>> The Shell text display is a subclass of a subclass of a class that
>> contains a subclass of Toplevel with the complete IDLE Menu and a Text
>> widget wrapper.  Again, this is too much baggage for an application
>> console.
>>
>> The idlelib ColorDelegator syntax highlighter can be reused with a Text
>> instance.  See turtledemo.__main__ for an example.  I don't know if (or
>> how) IDLE's autocompletion modules could be reused in their current
>> state.  I believe Shell's history 'list' consists of the statements in
>> the Text instance prefixed by the '>>> ' prompt.
>
> Thanks! I'll try to browse my way through the source code, these details
> help a lot. I still haven't understood the difference between exec() and
> eval(). I understand that for statements you want to exec them, for
> expressions you eval it and print the result. When the user has entered
> code, how does the REPL know if it should be eval'ed or exec'ed? I
> assume that you don't try to parse the Python code manually to find this
> out? Or you try to eval(), and if it doesn't compile, you exec()?

Python expressions are also statements.  Python REPLs exec statements. 
But to make Read-Exec-Print work like traditional Read-Eval-Print, 
Python, in interactive mode, echos the value of expression statements 
(and assign it to _ for later reuse).  So '2 + 2' echos 4 in REPL, or at 
least in the console and IDLE, '2 + 2' is useless in a program run in 
batch mode.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Application console for Tkinter program? Christian Gollwitzer <auriocus@gmx.de> - 2016-03-05 08:52 +0100
  Re: Application console for Tkinter program? Terry Reedy <tjreedy@udel.edu> - 2016-03-05 05:15 -0500
    Re: Application console for Tkinter program? Christian Gollwitzer <auriocus@gmx.de> - 2016-03-05 12:45 +0100
      Re: Application console for Tkinter program? Terry Reedy <tjreedy@udel.edu> - 2016-03-05 16:16 -0500
        Re: Application console for Tkinter program? Christian Gollwitzer <auriocus@gmx.de> - 2016-03-06 10:23 +0100
          Re: Application console for Tkinter program? Terry Reedy <tjreedy@udel.edu> - 2016-03-06 07:12 -0500

csiph-web