I have a program that takes a very long time to run, and I want it to be able to do what it needs to do but then if the user hits a specific key then I want the loop to break at a certain point. Most Q&A's I have seen pertaining to this problem prompt the user to enter something on each iteration of the loop, however I do not want this. I want the loop to run undisturbed until it needs to quit.
The script will be running as an executable in a command prompt (Windows) so I guess the user could just close the window but I want the loop to break at a certain point. For example:
while True:
print "Doing whatever I feel like"
userinput = raw_input()
if userinput == 'q':
break
So this keeps printing until the user enters 'q', but it prompts the user for input each iteration. How can I avoid this?