title: why args.add_argument works when given in two separate statements but not one in python?
body: <p>I am trying to use argparse module to parse the arguments in command line.
  here is the sample code</p>
  
  <pre><code>import argparse
  parser = argparse.ArgumentParser()
  parser.add_argument('bar')
  parser.add_argument('-foo')
  args=parser.parse_args()
  print args
  </code></pre>
  
  <p>running this</p>
  
  <pre><code>python argparsing.py "hello"
  Namespace(bar='hello', foo=None)
  </code></pre>
  
  <p>however, this does not work</p>
  
  <pre><code>import argparse
  parser = argparse.ArgumentParser()
  parser.add_argument('bar','--foo')
  #parser.add_argument('-foo')
  args=parser.parse_args()
  print args
  </code></pre>
  
  <p>running this gives error</p>
  
  <pre><code>python argparsing.py "hello"
  Traceback (most recent call last):
    File "argparsing.py", line 3, in &lt;module&gt;
      parser.add_argument('bar','-foo')
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1267, in add_argument
      kwargs = self._get_optional_kwargs(*args, **kwargs)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1397, in _get_optional_kwargs
      raise ValueError(msg % tup)
  ValueError: invalid option string 'bar': must start with a character '-'
  </code></pre>
  
  <p>The only difference between the two is I am adding argument separately (in two lines) in the first code but adding them in the same line as one statement in the failed code.
  can someone help me understand this better?</p>