On 11/2/2017 8:53 PM, Steve D'Aprano wrote:
On Fri, 3 Nov 2017 09:20 am, Terry Reedy wrote:
This seems like a bug in how Python interacts with your console. On
Windows, in Python started from an icon or in Command Prompt:
>>> for c in 'abc': print(c, end='')
...
abc>>>
That's still unfortunate: the prompt is immediately after the output, rather
than starting on a new line.
I agree. It is just less bad than backspacing into user output first.
It is easy for IDLE to detect if the prompt needs a \n prefix. I am
guessing that this is harder on consoles, and OS dependent.
IDLE adds \n if needed, so prompts always starts on a fresh line.
>>> for x in 'abcdefgh':
print(x, end='')
abcdefgh
>>>
The prompts and the output aren't aligned -- the prompts are indented by an
additional space. Is that intentional?
A copy-paste error (I rechecked) that I should have noticed.
Does IDLE do this only when writing to an actual console?
IDLE does this when Python writes to its Shell via stdout or stderr.
Because if it does
so even when output is redirected to a file, adding an extra, unexpected
newline would be a bug in IDLE.
IDLE compiles and execs your code. During the exec call, IDLE only sees
output sent to its stdout/stderr replacements. If your code sends
output to a file it opens, IDLE is not involved.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list