title: Can I write an ipython script that quits ipython?
body: <p>I would like a script that does something like:</p>
  
  <pre><code>x = 1
  x += 1
  exit
  </code></pre>
  
  <p>when I just type these in sequentially to ipython.</p>
  
  <p>If I try just putting these in script.py and doing %run script.py, it doesn't work (neither does %run -i):</p>
  
  <pre><code>In [1]: %run test.py
  ---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  /Users/david/nice_pngs/test.py in &lt;module&gt;()
        1 x = 1
        2 x += 1
  ----&gt; 3 exit
  
  NameError: name 'exit' is not defined
  
  In [2]: %run -i test.py
  
  In [3]: 
  </code></pre>