title: Python argparse: how to reference a parameter with a dash in it
body: <p>I'm using <a href="https://docs.python.org/3/library/argparse.html#module-argparse" rel="nofollow noreferrer">argparse</a> and I'd like to specify the positional argument with a dash in it. argparse seems to let me do this. Indeed, it shows up in the Namespace of parse_args(), but I cannot figure out how to reference the corresponding value. Here's a minimal example (notice the dash in 'a-string'):</p>
  <pre><code>#!/usr/bin/env python3
  
  import argparse
  
  parser = argparse.ArgumentParser()
  parser.add_argument('a-string', help='A string')
  
  args = parser.parse_args()
  
  # AttributeError: 'Namespace' object has no attribute 'a_string'
  #print(&quot;Argument was: &quot; + args.a_string)
  
  # TypeError: 'Namespace' object is not subscriptable
  #print(&quot;Argument was: &quot; + args['a-string'])
  
  # AttributeError: 'Namespace' object has no attribute 'a'
  #print(&quot;Argument was: &quot; + args.a-string)
  
  # I give up. Ask StackOverflow.
  </code></pre>
  <p>I initially thought to address this with the <a href="https://docs.python.org/3/library/argparse.html#dest" rel="nofollow noreferrer">dest</a> argument to <a href="https://docs.python.org/3/library/argparse.html#the-add-argument-method" rel="nofollow noreferrer">add_argument</a>, but I get &quot;ValueError: dest supplied twice for positional argument&quot; if I add dest to a positional argument. How do I reference the value of this positional argument?</p>