title: Python capture user input while in loop executing other code?
body: <p>I am running sequential code in a loop that is doing various computations, and occasionally printing out results that I monitor in the console.</p>
  <p>What I'd like to do is be able to hit keyboard buttons, while the program is running, and then save and process that input (e.g. as a command to change some parameter) on the next start iteration of that loop.</p>
  <p>Here's the structure of the code I'm running:</p>
  <pre><code>for i in range(0, itrs):
      # ideally at the start of each loop: 
      # check to see if user pressed keybutton during prev loop itr, 
      # but don't wait / poll for it! 
  
      # userKeyInput = checkIfUserPressedKey()
      # param = modify(userKeyInput)
  
      doSequentialComputation(param)
  </code></pre>
  <p>Would the solution involve some notion of threading or interrupt? I could probably come up with a solution that involves file I/O, which wouldn't be terrible, but I was thinking maybe Python has something simpler that would work.</p>