Forums

how to delete content that I typed?

Hi, everyone! I am pretty new to this programming thing and I will type a lot of silly command to learn how to programming. So, how could I delete something I typed into console? Well, I already typed something in py console, and I don't want to see what I typed last time, it is really messy. Could someone tell me how to clear what I typed in console? Thanks a lot!

You can't really do that. If it really bothers you, start a new console.

in python console no idea, but in a normal bash you can use clear command to empty the screen

Actually, Glenn wasn't quite right about there being no way to clear the screen in a Python console -- hit control-L, and that should do the job.

I used the popular method with os and/or subprocess module for a long time. I just put it in a pypi repo because I got sick of typing system(‘clear’) all the time.

pip install clear-screen (or pip3)

From clear_screen import clear

clear()

It works on all statems and python2 or 3 and clear() is easier to type:)

Neat, I didn't know that existed!

I am in the file editor and running my code in the little console below. When I do os.system("clear") OR clear() it does work but it does not exterminate all the prior data.

Is there a way that if I scroll up I do not see all the junk that was just cleared? Thanks!

Right, the clear-screen commands just clear the bit that is currently visible, so as you say you can still scroll back to see older stuff that was previously scrolled off the screen.

The easiest way to get rid of that is to close the console entirely using Control-D or the exit() function -- then if you run the code again, it will start a fresh console and you won't have all of the old stuff there. Of course, that comes with the downside that it does take a bit longer to run the code, because it has to start up a fresh console to run it in.

Thanks!

how can I copy my output to document without disrupting the data inputted. When I copy paste it to word document it does not look the same

Where are you copying it from?