title: How do I check if the python debug option is set from within a script
body: <p>If I'm in debug mode, I want to do other stuff than when I'm not.</p>
  
  <pre><code>if DEBUG:
      STORED_DATA_FILE = os.path.join(TEMP_DIR, 'store.dat')
      LOG_LEVEL = logging.DEBUG
      print "debug mode"
  else:
      STORED_DATA_FILE = os.path.join(SCRIPT_PATH, 'store.dat')
      LOG_LEVEL = logging.INFO
      print "not debug mode"
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>python script.py
  not debug mode
  
  python -d script.py
  debug mode
  </code></pre>
  
  <p>How can I detect that? It certainly isn't using the <code>__debug__</code> variable.</p>