Welcome, guest | Sign In | My Account | Store | Cart

This program can actually time anything you want, not just eggs. Unfortunately, it only runs on Windows.

Python, 27 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
try:
    import os
    import sys
    import time
    import msvcrt
    import winsound
except ImportError, error:
    sys.stdout.write('ImportError: %s' % error)
    sys.exit(1)

def main():
    try:
        alarm(*map(float, sys.argv[1:]))
    except:
        name = os.path.basename(sys.argv[0])
        sys.stdout.write('Usage: %s <hours> <minutes> <seconds>' % name)

def alarm(hours, minutes, seconds):
    time.sleep(abs(hours * 3600 + minutes * 60 + seconds))
    while msvcrt.kbhit():
        msvcrt.getch()
    while not msvcrt.kbhit():
        winsound.Beep(440, 250)
        time.sleep(0.25)

if __name__ == '__main__':
    main()

Do you have an oven without a timer and your computer? Then let the computer do the work of the timer!

1 comment

klausman-aspn 16 years, 11 months ago  # | flag

Alternative. A cross-platform (where Tkinter is available) program doing the same:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/124894