tell whether python is in -i mode
<p>How can you tell whether python has been started with the -i flag?</p>

<p>According to <a href="http://www.wingware.com/psupport/python-manual/2.6/using/cmdline.html" rel="nofollow">the docs</a>, you can check the PYTHONINSPECT variable in os.environ, which is the <em>equivalent</em> of -i. But apparently it doesn't work the same way.</p>

<p>Works:</p>

<pre><code>$ PYTHONINSPECT=1 python -c 'import os; print os.environ["PYTHONINSPECT"]'
</code></pre>

<p>Doesn't work:</p>

<pre><code>$ python -i -c 'import os; print os.environ["PYTHONINSPECT"]'
</code></pre>

<p>The reason I ask is because I have a script that calls sys.exit(-1) if certain conditions fail. This is good, but sometimes I want to manually debug it using -i. I suppose I can just learn to use "PYTHONINSPECT=1 python" instead of "python -i", but it would be nice if there were a universal way of doing this.</p>
