title: Can't get argparse to read quoted string with dashes in it?
body: <p>Is there a way to make argparse recognize anything between two quotes as a single argument? It seems to keep seeing the dashes and assuming that it's the start of a new option</p>
  
  <p>I have something like:</p>
  
  <pre><code>mainparser = argparse.ArgumentParser()
  subparsers = mainparser.add_subparsers(dest='subcommand')
  parser = subparsers.add_parser('queue')
  parser.add_argument('-env', '--extraEnvVars', type=str,
                          help='String of extra arguments to be passed to model.')
  ...other arguments added to parser...
  </code></pre>
  
  <p>But when I run:</p>
  
  <pre><code>python Application.py queue -env "-s WHATEVER -e COOL STUFF"
  </code></pre>
  
  <p>It gives me:</p>
  
  <pre><code>Application.py queue: error: argument -env/--extraEnvVars: expected one argument
  </code></pre>
  
  <p>If I leave off the first dash, it works totally fine, but it's kind of crucial that I be able to pass in a string with dashes in it. I've tried escaping it with \ , which causes it to succeed but adds the \ to the argument string Does anyone know how to get around this? This happens whether or not -s is an argument in parser.</p>
  
  <p>EDIT: I'm using Python 2.7.</p>
  
  <p>EDIT2: </p>
  
  <pre><code>python Application.py -env " -env"
  </code></pre>
  
  <p>works perfectly fine, but</p>
  
  <pre><code>python Application.py -env "-env"
  </code></pre>
  
  <p>does not.</p>
  
  <p>EDIT3: Looks like this is actually a bug that's being debated already: <a href="http://www.gossamer-threads.com/lists/python/bugs/89529">http://www.gossamer-threads.com/lists/python/bugs/89529</a>, <a href="http://python.6.x6.nabble.com/issue9334-argparse-does-not-accept-options-taking-arguments-beginning-with-dash-regression-from-optp-td578790.html">http://python.6.x6.nabble.com/issue9334-argparse-does-not-accept-options-taking-arguments-beginning-with-dash-regression-from-optp-td578790.html</a>. It's only in 2.7 and not in optparse. </p>
  
  <p>EDIT4: The current open bug report is: <a href="http://bugs.python.org/issue9334">http://bugs.python.org/issue9334</a></p>