[Tutor] How to clear the screen

W W srilyk at gmail.com
Mon Oct 20 12:45:57 CEST 2008


On Mon, Oct 20, 2008 at 3:13 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> "Chris Fuller" <cfuller084 at thinkingplanet.net> wrote
>
>  want to clear the screen, printing the control sequence ESC[2J is all you
>> need.
>>
>>  print chr(0x1b) + '[2J'
>>>>>
>>>>
I don't know if this is the most graceful solution... but it seems to work:
import os

if os.system('cls') == 0:
    pass
elif os.system('clear') == 0:
    pass
else:
    print 'No clear command available'

That should take care of most of your OS' out there...

HTH,
Wayne

-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081020/f904e9a5/attachment.htm>


More information about the Tutor mailing list