stopwatch

By Hal Canary, 2011-07-15 12:00:00 (link)

#!/usr/bin/python """Stopwatch program.

Hit 'Enter' to save a time.

Hit 'Ctrl-c' to stop the script
"""
from datetime import datetime, date, time
import time, sys
start = datetime.now()
print __doc__
try:
    while True:
        time.sleep(0.071)
        sys.stdout.write('\b'*22)
        sys.stdout.write(str(datetime.now() - start))
        sys.stdout.flush()
except KeyboardInterrupt:
    sys.stdout.write('\n\n')

(back)