title: How to determine if Python script was run via command line?
body: <h2>Background</h2>
  
  <p>I would like my Python script to pause before exiting using something similar to:</p>
  
  <p><code>raw_input("Press enter to close.")</code></p>
  
  <p>but only if it is NOT run via command line. Command line programs shouldn't behave this way.</p>
  
  <h2>Question</h2>
  
  <p>Is there a way to determine if my Python script was invoked from the command line:</p>
  
  <p><code>$ python myscript.py</code></p>
  
  <p>verses double-clicking <code>myscript.py</code> to open it with the default interpreter in the OS?</p>