3

I need to clear a printed line, but so far I have found no good answers for using python 3.7, IDLE on windows 10. I am trying to make a simple code that prints a changing variable. But I don't want tons of new lines being printed. I want to try and get it all on one line.

Is it possible to print a variable that has been updated later on in the code?

Do remember I am doing this in IDLE, not kali or something like that.

Thanks for all your help in advance.

hemopoco
  • 31
  • 1

1 Answers1

1

The Python language definition defines when bytes will be sent to a file, such as sys.stdout, the default file for print. It does not define what the connected device does with the bytes.

When running code from IDLE, sys.stdout is initially connected to IDLE's Shell window. Shell is not a terminal and does not interpret terminal control codes other than '\n'. The reasons are a) IDLE is aimed at program development, by programmers, rather than program running by users, and developers sometimes need to see all the output from a program; and b) IDLE is cross-platform, while terminal behaviors are various, depending on the system, settings, and current modes (such as insert versus overwrite).

However, I am planning to add an option to run code in an IDLE editor with sys.stdout directed to the local system terminal/console.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52