How is possible to create a python shell script like top unix command? -


I need to create a Python shell script which refreshes every N seconds like the top UNIX command. What is the best way to do this?

One way to do this is by writing a script prints your output (once), and Then run your script using the command. The Clock command will automatically clear the screen and execute your script every few seconds (usually 2 by default).

If you really want to do this in pure Python, then you can go easy enough if you know that your terminal is VT100-compatible:

  print "\ x1b [h \ x1b [2J", print "hello clean world"]  

Comments