gamers beware
gamers beware

Reputation: 53

How to edit the terminal without clearing it?

The way I usually edit the terminal is by writing:

Import os
While "something":
   "Do something"
   Lambda: os.system("cls")
   print("result")

For clarification, I don't want to clear the console, I want to edit it directly so I can make a similar effect to the spinning line ('|','/','-','|','-','\').

Upvotes: 1

Views: 476

Answers (2)

Johnny
Johnny

Reputation: 211

sys.stdout.write('\b ') will move the cursor back and replace the text with an empty space.

Upvotes: 1

slesh
slesh

Reputation: 2017

The short answer - it's not possible due to the nature of how text console works. It always prints text. If you need to have a static text and an ability to edit it, you have to keep initial text in memory, edit it and re-print it again by clearing previous text on the screen.

Upvotes: 1

Related Questions