Floyd L. Davidson wrote: > [EMAIL PROTECTED] wrote: > >If I may recommend an alternative, > >print "\033[H\033[J" > Unfortunately, it is poor practice to hard code such sequences. > Instead the proper sequence should be obtained from the > appropriate database (TERMINFO or TERMCAP), and the easy way to > do that is, > tput clear
Or clear(1), as also mentioned earlier. Yes, definitely don't want to hardcode the sequence. Definitely do use the appropriate terminal capabilities database (terminfo or termcap) in the appropriate manner (e.g. clear(1) or tput clear will handle that in the simple case of shell accessible means to clear the screen). Most UNIX(/LINUX/BSD/...) implementations support a large number of terminal types. E.g. on my system, I check and find that there are 1470 unique terminal types (descriptions) supported - and that's not including multiple aliases for the same terminal type/description (but it does count distinct names/files which have differing configurations, even if they are for the same terminal - such as changing certain options or behavior of a terminal, or using the terminal in distinct modes). Among those terminal types on my system, I find 154 distinct means of clearing the screen. Just for illustrative purposes, here are the top 10 I find, with count of how many distinct types (descriptions) use that particular sequence: 236 clear=\E[H\E[J, 120 clear=^L, 120 clear=\E[H\E[2J, 64 clear=\EH\EJ, 61 clear=\E[2J, 42 clear=\E[H\E[J$<156>, 38 clear=^Z, 36 clear=\E[H\E[J$<50>, 31 clear=\E[H\E[J$<40>, 29 clear=\E[2J\E[H, And of course, sending the wrong sequence (e.g. like trying some to see what works) can be highly problematic - it can do very nasty things to some terminals. E.g. I own one terminal, which among sequences it supports, is one which effectively says interpret the following hexadecimal character pairs as bytes, load them into RAM, and execute them - a relatively sure-fire way to crash the terminal if it is sent garbage (I used to run into that and other problems with some BBS systems that would presume everyone must be running something ANSI capable or that it was safe to do other tests such as see if certain sequences would render a blue square on one's screen). references: "system" call/function, in various programming languages clear(1) tput(1) terminfo(5) termcap(5) news:[EMAIL PROTECTED] news:[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list