I have a test case I'm building up whereby I want to start or stop a timer with a keypress, but I can't figure out how to keep my routine alive... 'g' should start the timer (and continually repeat), and 's' should stop the timer. 'g' can then start the timer, etc. Instead, 'g' starts the timer and 's' does nothing. What am I doing wrong?
Code:
#!/usr/bin/env python
import time, sys
def print_something(status):
while(status):
print 'the time: ' , time.ctime()
time.sleep(1);
def main():
result = 1
print 'starting time: ' , time.ctime()
result = raw_input('press g to start timer, s to stop.\n')
while(result is 'g'):
print_something(True)
result = ''
result = None
time.stop()
main()