Hi,
I am trying to get a piece of code going, in which the user has a set amount of time in which to enter some text. If they do not and the time expires or if they do before the time has expired it should move (instantly) on depending on whether anything has been entered.
Therefore using sleep wont work because I want the code to move on as soon as the user has finished entering text.
I have also looked at threading which seems to work better, I can get it to wait for user input but not sure how to make it stop once it is found! Ill show you the relevant code bits (obviously incomplete):
Code:
t = threading.Timer(30.0, listening(thisWord)
t.start()
where listening is something like:
Code:
def listening(thisWord):
signal = raw_input(thisWord)
return signal
I have tried added conditionals
Code:
If signal != None:
set some kind of flag or force exit...
M questions are -
is threading the way I want to do my original task?
how can I escape the thread early if signal becomes != None ?
I am rather new to python by the way
Cheers
Tom
Bookmarks