title: Get secondary input in Python to control history
body: <p>I'm wanting to build a "input history" script within Python 2.x, but I'm having a bit of trouble getting a secondary input while using <code>raw_input()</code>, and writing to what the user inputs.</p>
  
  <p>Because I found it a wee bit difficult to explain, I'm providing an example in JavaSript + HTML to try and clear things up. </p>
  
  <h2>JavaScript + HTML Example</h2>
  
  <p>(In snippet form)
  <div class="snippet" data-lang="js" data-hide="true">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var input = document.getElementById("input"),
    button = document.getElementById("button"),
    ihistory = document.getElementById("ihistory"),
    history = [],
    position = 0,
    text = "";
  
  button.onclick = function() {
    if (input.value != "") {
      history.push(input.value);
      input.value = "";
      position++;
      input.focus();
    }
  };
  
  input.onkeydown = function(e) {
    if (e.keyCode == 38 &amp;&amp; position - 1 &gt;= 0) {
      e.preventDefault();
      position--;
      input.value = history[position].toString();
    } else if (e.keyCode == 40 &amp;&amp; position + 1 &lt;= history.length) {
      e.preventDefault();
      position++;
      input.value = history[position].toString();
    } else if (e.keyCode == 13) {
      button.click();
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input type="text" id="input"&gt;&lt;/input&gt;
  &lt;button id="button"&gt;Submit&lt;/button&gt;
  
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;hr /&gt;
  &lt;p&gt;To Submit text to the text to the history, press "submit".&lt;/p&gt;
  &lt;p&gt;To access previous history, press the up arrow key. To access future history, press the down arrow key.&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'm not sure it is possible to write to what the user inputs, so that they can edit it, etc, without writing C/++ code. I'm fine with it if it does require C/++, or if it requires any weird (but preferably small) modules.
  Also, I'm progamming this in a Linux environment, so I am not interested it Windows/Mac-only answers. </p>