title: How to pause and wait for command input in a Python script
body: <p>Is it possible to have a script like the following in Python?</p>
  <pre class="lang-none prettyprint-override"><code>...
  Pause
  -&gt;
  Wait for the user to execute some commands in the terminal (e.g.
    to print the value of a variable, to import a library, or whatever).
  The script will keep waiting if the user does not input anything.
  -&gt;
  Continue execution of the remaining part of the script
  </code></pre>
  <p>Essentially the script gives the control to the Python command line interpreter temporarily, and resume after the user somehow finishes that part.</p>
  <hr/>
  <p>What I come up with (inspired by the answer) is something like the following:</p>
  <pre><code>x = 1
  
  i_cmd = 1
  while True:
    s = raw_input('Input [{0:d}] '.format(i_cmd))
    i_cmd += 1
    n = len(s)
    if n &gt; 0 and s.lower() == 'break'[0:n]:
      break
    exec(s)
  
  print 'x = ', x
  print 'I am out of the loop.'
  </code></pre>