[Tutor] Backspace Escape Sequence; \b

Alan Gauld alan.gauld at btinternet.com
Tue Feb 7 19:42:09 CET 2012


On 07/02/12 17:19, Garland W. Binns wrote:
> Could someone please tell me a common or semi-frequent scenario in which
> a person would use a backspace escape sequence?

Do you mean backspace specifically or do you really mean backslash?

In other words are you looking for a use of literal backspaces in a 
string or are you looking at the use of escaped characters in general?

backspace specifically is not commonly used but is sometimes handy for 
positioning the cursor in the middle of a line.
eg

raw_input("Area:    acres\b\b\b\b\b\b\b\b")

Should output the prompt line with the cursor positioned in the gap 
between Area: and acres.


 >>> raw_input("Area:    acres\b\b\b\b\b\b\b\b")
Area: 45 acres
'45'
 >>>

But in the general sense there are lots of scenarios where we use 
escaped characters.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list