Jump to content
  • Advertisement
Sign in to follow this  
Durakken

Python universal CLS?

This topic is 3411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to find a way to make a quick clear screen command that works on all computers. I've looked around and can't find one...mainly people just saying that you have to know the system to know which one works... and then you can find the system, but then i don't know which cls works with which system and have no way of testing so is there a universal CLS out there for Python?

Share this post


Link to post
Share on other sites
Advertisement
The most portable method to clear a console window is to write a number of blank lines (i.e. newline characters), some number greater than 20 in general. However, remember that some users may have extremely large terminals, and stdout need not actually be connected to a terminal (it could be a file).

Share this post


Link to post
Share on other sites
Quote:
Original post by Durakken
I'm trying to find a way to make a quick clear screen command that works on all computers.


Sorry. Not possible. In any programming language.

Not all computers have a "screen", let alone a clearable one. Of course, by "screen" it appears that you really mean "console window". Python's output isn't even necessarily sent to a console window. Try using IDLE (the IDE that comes with Python) to run your program; now ask what the "clear screen" command ought to do there. Or try something like 'myfile.py > output.txt' from the command line; notice how nothing gets printed to "the screen" at all, but is instead dumped into the named text file.

If you are looking for the amount of control over "how the output looks" that "ability to clear the screen" implies, then you don't really want to just 'print' your output and will have to use something more sophisticated. Note that using more sophisticated tools effectively will require new code design skills that you probably haven't yet had a chance to practice.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!