Terry J. Reedy <tjre...@udel.edu> added the comment:

I don't know how many core devs would agree that inserting '\n' would be 
preferable.  They might say that users who want clean interaction should not 
use the 'end' parameter the way you did in interactive mode.

IDLE is more aimed at beginners and can be more protective and/or opinionated.  
In any case, I agree with whoever wrote or edited this part of IDLE before me 
as to what IDLE should do.

There are also technical  issues.  Interactive python uses the common features 
of the various OS text and line-oriented terminal/consoles.  These do not know 
and do not care that they are displaying python input and output.  They display 
chars received from the executing program and have no way of knowing that the 
last n chars match python's sys.ps1 or sys.ps2.  The prompts comes from python 
executing "input(prompt)" after user code finishes.  To conditionally insert a 
newline, python would have to keep track of whether or not the last char sent 
by user code was a newline or not.

IDLE, on the other hand, is customized to run python code.  It *emulates* 
interactive mode with exec() calls.  IDLE, not python, displays prompts however 
programmed to do so.  It is trivial to check whether the last char inserted in 
the text widget is '\n' or not.

Side note: you only need '-i' for interactive mode when you also run a file 
because 'python -i' by itself is the same as 'python'.

'python -i somefile' is different from 'python somefile' because in the latter 
case, python exits after executing somefile, whereas in the former case, python 
executes 'input(sys.ps1)' and possibly 'input(sys.ps2)' until told to quit.  
'Run module' in an IDLE editor emulates 'python -i <filename>'.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43402>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to