title: How to fix shebang flags that are not recognized on some systems
body: <p>For some reason, the <code>-O</code> (optimized) flag is not recognized in the shebang line on a Red Hat Enterprise Server (release 5.3) that I access.  On other systems, the flag is recognized without any issue.  </p>
  
  <p>Executing the script below on OS X works fine. Recognition of the <code>-O</code> flag can be verified because it enables (when absent) or disables (when given) anything under the <code>if __debug__</code> conditional:</p>
  
  <pre><code>#!/usr/bin/env python -O                                                                                                                                                                       
  
  if __name__ == '__main__':
  
      if __debug__:
          print 'lots of debugging output on'
  
      print 'Fin'
  </code></pre>
  
  <p>Executing the same script on the RHE system result in:</p>
  
  <blockquote>
    <p>/usr/bin/env: python -O: No such file
    or directory</p>
  </blockquote>
  
  <p>Without the <code>-O</code> flag, the script executes normally on the RHE system (i.e., the <code>__debug__</code> built-in variable will be set to <code>True</code>).</p>
  
  <p>Is there a cross-platform way to fix this issue?  Is there even a platform-specific way to fix the issue of flags on the shebang line to the python interpreter?</p>
  
  <p><strong>Edit:</strong>  Any other workarounds to setting the <code>__debug__</code> variable (without using shebang flags) interpreter-wide would also be interesting.</p>