Backspace behavior in Python statement, what is correct behavior of printing a ‘\b’ in code? [duplicate]

Expanded answer: The backspace doesn’t delete anything, it moves the cursor to the left and it gets covered up by what you write afterwards. If you were writing to a device that can display overstriking (such as an old-fashioned “hard copy” terminal, which works like a typewriter), you’d actually see the new character on top of the old one. That’s the real reason backspace has these semantics.

On the unix command line, the shell can be set to interpret backspace as meaning “erase”– unless it’s set to only treat delete this way. But that’s up to the program reading your input.

Leave a Comment