NOTES: Running Python 2.7, working on a macbook (OSX)
I want to query my user for an input, but if no input occurs after a time interval, run something else and try again. Here's what I have written:
import sys, select
def test():
waittime = 4
i, o, e = select.select( [sys.stdin], [], [], waittime)
if i:
print 'got i'
else:
print 'did not get i'
test()
What this DOES: If user does not press [return], waits 3 seconds, prints 'did not get i', reruns the function. If user presses [return], if (i) statement runs indefinitely.
What I WANT it do do: If the user presses [return], print 'got i', rerun the function, WAIT FOR USER TO PRESS RETURN. If user does not press return, wait three seconds, print 'did not get i', try again.
Thanks in advance for any help! -Erik