Message251051
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 |
|
Date |
User |
Action |
Args |
2015-09-19 04:00:34 | martin.panter | set | recipients:
+ martin.panter, ezio.melotti, mrabarnett, Jared Bevis |
2015-09-19 04:00:34 | martin.panter | set | messageid: <1442635234.0.0.491843898602.issue25174@psf.upfronthosting.co.za> |
2015-09-19 04:00:33 | martin.panter | link | issue25174 messages |
2015-09-19 04:00:33 | martin.panter | create | |
|