clear terminal (and history!) in Python -


this almost duplicate of clear terminal in python, not quite.

that question reads: standard "comes batteries" method exist clear terminal screen python script, or have go curses (the libraries, not words) ?

all of responses there result in happens when enter clear on terminal - on screen disappears except empty command line @ top. but, if you'd like, can scroll see doing earlier.

i'm looking way this, not allow user scroll up. it's equivalent of command+k on macos.

the application multiplayer card game, , don't want player able scroll see player's hand.

you use subprocess.call() standard library subprocess module send reset command terminal reinitialize terminal , in effect similar clear clear scrollback history.

import subprocess subprocess.call('reset') 

alternatively, have learned this answer, can use command tput reset instead, clear terminal instantly, whereas reset alone experience slight delay. can called subprocess.call() follows:

subprocess.call(['tput', 'reset']) 

for more info on reset command, do:

$ man reset 

for more info on subprocess module, see the documentation.

i have tested both of these on ubuntu, work on osx/macos well. if not, perhaps can use subprocess combined this solution, unable test that.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -