title: Python getopt recognizing options as arguments
body: <p>I'm trying to parse some options when running a Python script.</p>
  
  <pre><code>def main(argv):
      try:
          opts, args = getopt.getopt(argv,"a:p:i:r",["algo=", "population=", "iterations=", "random"])
      except getopt.GetoptError:
          printUsage()
          sys.exit(1)
      print(args, opts)
      #Afterwards, I parse the options
      #...
  
  if __name__ == "__main__":
      main(sys.argv[1:])
  </code></pre>
  
  <p>However, when I run this</p>
  
  <pre><code>python tsp.py cities.txt -p 4
  </code></pre>
  
  <p>The <code>print(args, opts)</code> yields this.</p>
  
  <pre><code>(['cities.txt', '-p', '4'], [])
  </code></pre>
  
  <p>Why is it parsing options as arguments?</p>