[Tutor] Python Timer

Joe Chiocchi x.ultimate at verizon.net
Wed Nov 17 21:07:26 CET 2004


Ok, so right now I am in the progress of writing it. I'm using ansi characters so that I can clear the line and stuff. Here is an example of just a counter..(counts up every second until u stop it)
You have to make sure you run it python unbuffered mode.

#!/usr/bin/python -u

from time import sleep

def ansi(str):
        return chr(27)+'['+str
x = 0
while 1:
        x=x+1
        print x,
        sleep(1)
        print ansi('0E')+ansi('K'),

Ok so the plan is to integrate this into my timer. I just need to figure out how to compare it the time right now, and the time at which I want it to end.

Thanks


More information about the Tutor mailing list