Search code examples
python-3.xpython-idlebackspace

Implementing a backspace in Python 3.3.2 Shell using Idle


There are several folks on here looking for backspace answers in Python. None of the questions I have searched have answered this for me, so here goes:

The Simple Goal: be able to print out a status string on one line, where the next status overwrites the first. Similar to a % complete status, where instead of scrolling a long line of 1%\n, 2%, ... etc. we just overwrite the first line with the newest value.

Now the question. When I type this in idle: print("a\bc") I get this as output: ac with what looks like an odd box with a circle between the 'a' and 'c'. The same thing happens when using sys.stdout.write().

Is this an Idle editor setting/issue? Does anyone even know if what I am trying is possible in the Idle Shell?

Thanks for any insight.

PS: Running Python 3.3.2 Idle on Windows 7, 64-bit system.

EDIT: Copying the output in Notepad++ is revealing that Python is printing out a 'backspace' character, and not actually going back a space. Perhaps what I am trying to accomplish is not possible?


Solution

  • Edit:

    Apparently the carriage return \r and the backspace \b won't actually work within Idle because it uses a text control that doesn't render return/backspace properly.

    You might be able to write some sort of patch for Idle, but it might be more trouble than it's worth (unless you really like Idle)