Timer events

Jeff Epler jepler at unpythonic.net
Mon May 17 21:14:14 EDT 2004


umm, why not convert the given time into seconds, and then call sleep
once?

def get_time(): # taken from EAS' code
    print "Enter the hours, minutes, and seconds you want the computer to wait."
    
    while hou < 0 or hou > 23:
        hou = input("Hours: ")   # All the usual warnings about input() apply
    while min < 0 or min > 59:
        min = input("Minutes: ")
    while sec < 0 or sec > 59:
        sec = input("Seconds: ")

    # my innovation
    return sec + 60 * min + 60 * 60 * hou

time.sleep(get_time())
print "\a\a\a"

exit = raw_input("\nPress enter to exit.")




More information about the Python-list mailing list