Printing to console (No Scroll)

Joe Francia usenet at -OBFUSCATION-joefrancia.com
Wed Jan 14 13:49:07 EST 2004


Totte Karlsson wrote:
> Hi,
> How can I print to the console without having it scrolling to a new line for
> each print statement?
> I want to print a count down in the console, but for each count it scrolls
> the screen (of course).
> 
>  Is there another way?
> 
> Here is the simple script for now
> 
> print "Closing window in :"
> for second in range(10):
>     time.sleep(1)
>     print `10-second` +" seconds"
> 
> thanks
> /totte

This works for me:

import time, sys
for second in range(10):
     time.sleep(1)
     sys.stdout.write(`10-second` + " seconds ")
     sys.stdout.flush()



More information about the Python-list mailing list