title: usage function doesn't work with getopt
body: <p>I have a problem with a usage function in Python. This is a part of my main function:</p>
  
  <pre><code>def main(argv):
      try:
              opts, args = getopt.getopt(argv, 'hi:o:tbpms:', ['help', 'input=', 'output='])
              if not opts:
                      print 'No options supplied'
                      usage()
      except getopt.GetoptError,e:
             print e
             usage()
             sys.exit(2)
  
      for opt, arg in opts:
              if opt in ('-h', '--help'):
                      usage()
                     sys.exit(2)
  if __name__ =='__main__':
      main(sys.argv[1:])
  </code></pre>
  
  <p>and I define a usage function as well </p>
  
  <pre><code>def usage():
      print "\nThis is the usage function\n"
      print 'Usage: '+sys.argv[0]+' -i &lt;file1&gt; [option]'
  </code></pre>
  
  <p>but when I run my code as <code>./code.py</code> or <code>./code.py -h</code> (it is executable) I got anything but the Python help.</p>