Martin Panter added the comment:

Python itself doesn’t treat backspace specially. What you are probably seeing 
is the terminal interpreting the backspace specially by moving the cursor left 
(without erasing anything).

>>> s = "12345" + '\b' + '6'
>>> s
'12345\x086'
>>> s[5]  # ASCII code for backspace is 0x08
'\x08'

If you redirect the output to a file or other program, you will also see the 
backspace code is still there:

$ python2 -c 'print "12345" + "\b" + "6"' | hexdump -C
00000000  31 32 33 34 35 08 36 0a                           |12345.6.|
00000008

----------
components:  -Regular Expressions
nosy: +martin.panter
resolution:  -> not a bug
status: open -> closed

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

Reply via email to