Reputation: 646
Compare:
for item in range(0, 5):
sys.stdout.write('c')
for item in range(0, 5):
sys.stdout.write('\b')
Works as you would imagine, but:
for item in range(0, 5):
sys.stdout.write('\n')
for item in range(0, 5):
sys.stdout.write('\b')
still leaves you with five newline characters. Any ideas?
Upvotes: 10
Views: 10646
Reputation: 82924
This is absolutely nothing to do with Python. It's your console driver that handles any visual effects. Most of them will emulate an ASR33 teletype ... backspace means move the print head one space back towards the start-of-line position, if possible.
Upvotes: 0
Reputation: 304127
It may seem reasonable today to expect backspace to be able to work over newline characters, on a console but that would not be backward compatible with teletypes as there is no reverse linefeed.
Upvotes: 17
Reputation: 375484
This is about the behavior of console windows: backspaces only work within a line, they won't backup over newlines.
Upvotes: 4