title: How to flush the input stream?
body: <p>I'm writing a simple alarm utility in Python.</p>
  <pre><code>#!/usr/bin/python
  
  import time
  import subprocess
  import sys
  
  alarm1 = int(raw_input(&quot;How many minutes (alarm1)? &quot;))
  
  while (1):
      time.sleep(60*alarm1)
      print &quot;Alarm1&quot;
      sys.stdout.flush()
      doit = raw_input(&quot;Continue (Y/N)?[Y]: &quot;)
      print &quot;Input&quot;,doit
      if doit == 'N' or doit=='n':
          print &quot;Exiting.....&quot;
          break
  </code></pre>
  <p>I want to flush or discard all the key strokes that were entered while the script was sleeping and only accept the key strokes after the raw_input() is executed.</p>
  <p>I'm running this on Windows XP.</p>