[issue25174] Backspace Escape Character at End of String

2015-09-18 Thread Martin Panter

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
  31 32 33 34 35 08 36 0a   |12345.6.|
0008

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

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25174] Backspace Escape Character at End of String

2015-09-18 Thread Jared Bevis

New submission from Jared Bevis:

I'm a new python learner but I noticed inconsistent behavior of the backspace 
character when used in strings.  I'm running 2.7.10.  Whenever the backspace 
character '\b' is at the very end of a string, nothing happens, but if it is in 
the middle of string it behaves as expected.  

For example:
print "12345" + '\b'
returns:
>>>12345

But:
print "12345" + '\b' + '6'
returns:
>>> 12346

--
components: Regular Expressions
messages: 251049
nosy: Jared Bevis, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Backspace Escape Character at End of String
type: behavior
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com