title: type as you go input for python, rerun code on change to input
body: <p>I'm trying to create an autocomplete demonstration using some data in elasticsearch. I have a simple code that takes an input, then returns a list of recommended autocompletes.</p>
  <pre><code>while True:
      search = input(&quot;start typing&quot;)
  
      body = {
           &quot;size&quot;: 5,
           &quot;query&quot;: {                                                     
               &quot;multi_match&quot;: {
                   &quot;query&quot;: &quot;'&quot;+search+&quot;'&quot;                         
               }                               
           }                
       }
      res = es.search(index=&quot;autocomplete&quot;, body=body) //getting the suggestions
      for hit in res['hits']['hits']:
          doc = hit[&quot;_source&quot;][&quot;company_name&quot;]
          print(doc) //printing the suggestions
  </code></pre>
  <p>Right now it works like this:
  Say I want to search for &quot;Google&quot;. terminal will say <code>start typing!</code> and I'll type &quot;G&quot;, press enter and I'll get a list of autocomplete suggestions, then it will say <code>start typing!</code> and I'll type &quot;Go&quot; and get a new list of suggestions, then next time I type &quot;Goo&quot;, etc. just trying to see how the autocomplete suggestions change as I type more and more of the word.</p>
  <p>I would like to get it to where if I type or change anything, it will automatically run the autocomplete code, so I can just type &quot;G&quot;, it runs, then I type &quot;o&quot; which adds it to the previous &quot;G&quot; so it runs for &quot;Go&quot;, then I type another &quot;o&quot;, &quot;g&quot;,&quot;l&quot;,&quot;e&quot;. Basically I want it to run like a normal autocomplete for Google search, where as you keep typing it will update the suggestions. Is there a way to do this in python?</p>