[Tutor] Backspace Escape Sequence; \b

Peter Otten __peter__ at web.de
Tue Feb 7 20:13:55 CET 2012


Steven D'Aprano wrote:

> Peter Otten wrote:
>> 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?
>> 
>> Does
>> 
>> $ python -c 'print "this is b\bbo\bol\bld\bd"' | less
>> 
>> qualify? If you are using (e. g.) Linux this technique is used to show
>> some text in boldface
> 
> Gah, that has got to be the ugliest hack in the universe.
> 
> I don't think that is guaranteed to work everywhere. less supports the \b
> trick, but the Python interactive interpreter doesn't support it directly.

Well, the beauty in that hack is that output devices that don't understand 
it usually interpret "\b" as backspace and thus still produce a readable 
fallback.



More information about the Tutor mailing list