Terry J. Reedy added the comment:

I closed #24572 as a duplicate of this. It is the same issue except for 
printing \r instead of \b.  These issues are not about responses to keyboard 
actions when entering text into an Idle editor window.  During entry, just 
about any cntl/alt/function/shift/key combination can be intercepted to and 
translated to arbitrary action. They are also not about REPL echo.  For 3.4+ 
Win7, both console Python and Shell echo '\b\t\x08\x09' as '\x08\t\x08\t'. 
Carol's report suggest that the same is true on Mac also.

Both issues *are* about print(s, file=outfile), where s is the result of 
processing all args except 'file' and outfile defaults to sys.stdout. The print 
call is the same as outfile.write(s), so outfile (and sys.stdout) could be any 
object with a write method.

>>> print('hello\b\b\b\b\bHELLO')
helloHELLO
>>> import sys; sys.stdout.write('hello\b\b\b\b\bHELLO'+'\n')
helloHELLO
(I actually see the same circles as Al, but copy-paste does not seem to work as 
well for me.)

So both issues are about the effect of writing 'control chars', in particular 
\b and \r, to a file. Well, that depends on the file.  Some possibilities are 
copy as is (StringIO), encode and copy (disk file, socket), ignore, display as 
one glyph, display as multiple chars, non-destructively backspace (like 
backspace on typewriters and printing terminals and left-arrow elsewhere), or 
destructively backspace (like backspace on as most (all?) screen keyboards).  
After non-destructive movement of the 'cursor' position, the possibilities for 
following graphical chars are overwrite (like typewriters), replace, and insert 
(the modes sometimes selected by the Insert key). Non-destructive backspace 
followed by overwrite (meaning 'HELLO' printed on top of 'hello') is the 
original meaning of 'backspace'.

Having said all this, I am sympathetic to the idea that there should be an 
option to have 'print(ascii_string)' in user code give the same result in the 
console and Idle.  I think this would best be accomplished by a 
least-common-denominator SimpleTerm subclass of tkinter.Text put somewhere in 
the tkinter package. (This would be a new issue that should start on 
python-ideas list.)  However, I would consider something Idle specific.

Does the following work the same on *nix and Mac as Windows?

>>> print('hello\rHELLO')
HELLO  # helloHELLO with Win7 Idle

Are there any control-chars (other than \n) that work might work in the 
consoles on all three systems and that should be included?

Carol, another difference between the Windows console and Idle is that tk and 
hence Idle support the entire BMP subset of unicode.  This should also be 
mentioned in the doc.

----------
stage:  -> needs patch
type:  -> enhancement

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

Reply via email to