How to get a python script to invoke "python -i" when called normally?
<p>I have a python script that I like to run with <code>python -i script.py</code>, which runs the script and then enters interactive mode so that I can play around with the results.</p>

<p>Is it possible to have the script itself invoke this option, such that I can just run <code>python script.py</code> and the script will enter interactive mode after running?</p>

<p>Of course, I can simply add the <code>-i</code>, or if that is too much effort, I can write a shell script to invoke this.</p>

<p>I would simply accompany the script with a shell script that invokes it.</p>

<pre class="lang-sh prettyprint-override"><code>exec python -i "$(dirname "$0")/script.py"
</code></pre>

python python-interactive