title: Is there anyway to persuade python's getopt to handle optional parameters to options?
body: <p>According to the documentation on python's <code>getopt</code> (I think) the options fields should behave as the <code>getopt()</code> function. However I can't seem to enable optional parameters to my code:</p>
  
  <pre><code>#!/usr/bin/python
  import sys,getopt
  
  if __name__ == "__main__":
      try:
          opts, args = getopt.gnu_getopt(sys.argv[1:], "v::", ["verbose="])
      except getopt.GetoptError, err:
          print str(err)
          sys.exit(1)
  
      for o,a in opts:
          if o in ("-v", "--verbose"):
              if a:
                  verbose=int(a)
              else:
                  verbose=1
              print "verbosity is %d" % (verbose)
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>$ ./testopt.py -v
  option -v requires argument
  $ ./testopt.py -v 1
  verbosity is 1
  </code></pre>