Is is possible for a python script to know whether it is run with the interactive option '-i'?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/640389/tell-whether-python-is-in-i-mode">tell whether python is in -i mode</a><br>
  <a href="http://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode">Tell if python is in interactive mode</a>  </p>
</blockquote>



<p>Is there a way to check whether a python script has been run with the interactive option -i?</p>

<p>e.g.</p>

<pre><code>if interactive_mode:
    print 'I am in interactive mode!'
else:
    print 'I am in batch mode!'
</code></pre>

<p>Then call with    </p>

<pre><code>python hello_world.py
I am in batch mode!

python -i hello_world.py
&gt;&gt; I am in interactive mode!
</code></pre>
