3

I happen to be making an application that uses CLI.The problem I have is that I want to clean the screen to make it look better, but I don't know how to do it. I tried to use CLS and import os it but I get a zero and it doesn't do the job, any idea about how to do this?.

for example:

import os
print ("hello world")
os.system('cls') 

output:

hello world
♀Press any key to continue . . 

i try:

import os
clear = lambda: os.system('cls')
print ("hello world")
clear()

still gives the same result in visual studio, now, if I try by CLI it works. I really don't understand

Felipe
  • 71
  • 6
  • 1
    Does this answer your question? [How to clear the interpreter console?](https://stackoverflow.com/questions/517970/how-to-clear-the-interpreter-console) – RichieV Sep 21 '20 at 00:56
  • does not work =(, for some reason in vs does not work and still gives the same result – Felipe Sep 21 '20 at 01:00
  • By VS do you mean VS code? – Martheen Sep 21 '20 at 01:02
  • 2
    not, microsoft visual studio 2019 – Felipe Sep 21 '20 at 01:03
  • 2
    Your question seems to be specifically about Visual Studio 2019 for Python, you may want to add an appropriate tag, since most people won't be using that editor and the answer for Python in general has already been provided. – Grismar Sep 21 '20 at 01:15
  • thanks for your answer, I already made the change – Felipe Sep 21 '20 at 01:21

1 Answers1

4

I imagine you have moved beyond this issue now but I've just run into this issue myself using Python in Visual Studio 2022 on Windows 11 and found your question. Looks like its an open known bug with the "debug window" (python interpreter) in Visual Studio: https://github.com/microsoft/debugpy/issues/246.

If you uncheck Tee program output to Debug Output Window in the Python Debugging Options (see image)

enter image description here

then your posted code:

import os
print ("hello world")
os.system('cls') 

will clear the screen for you in the VS interpreter window.

Paul Marshall
  • 523
  • 4
  • 11