title: Why is KeyboardInterrupt not working in python?
body: <p>Why doesn't code like the following catch CTRL-C?</p>
  
  <pre><code>MAXVAL = 10000
  STEP_INTERVAL = 10
  
  for i in range(1, MAXVAL, STEP_INTERVAL):
      try:
          print str(i)
      except KeyboardInterrupt:
          break
  
  print "done"
  </code></pre>
  
  <p>My expectation is -- if CTRL-C is pressed while program is running, <code>KeyboardInterrupt</code> is supposed to leave the loop. It does not.</p>
  
  <p>Any help on what I'm doing wrong?</p>