title: Bash script: Open Python, execute some lines, then let user take control
body: <p>I have a Python program, A.py, that creates binary data upon completion. To help users analyze the output, I want to add a small script, B.sh, to the output directory that fires up a Python console and executes some commands, C, that load the data and prepare them such that a user sees what is available. After executing C, the script B.sh should keep the Python console open.</p>
  
  <p><strong>First attempt at B.sh:</strong> </p>
  
  <p>I figured out that</p>
  
  <pre><code>#!/bin/sh 
  xterm -e python
  </code></pre>
  
  <p>opens a Python console and keeps it open but doesn't execute anything within that console.</p>
  
  <p><strong>Second attempt at B.sh:</strong></p>
  
  <p>I figured out that </p>
  
  <pre><code>#!/bin/sh
  xterm -e python -i C.py
  </code></pre>
  
  <p>executes C.py (I'd prefer not to have to write an additional file for the startup commands, but I could live with that) and keeps the window open, but doesn't show what was done. More specifically, the user would be presented with the outputs of C, but not the command that were used to achieve the outputs.
   Instead,I'd like the user to be presented with a console like this:</p>
  
  <pre><code>&gt;&gt;&gt; [info,results] = my_package.load(&lt;tag&gt;)
  &gt;&gt;&gt; my_package.plot(results)
  &gt;&gt;&gt; print(info)
    &lt;output&gt;
  &gt;&gt;&gt; my_package.analyze(results)
    &lt;output&gt;
  &gt;&gt;&gt; 
  </code></pre>