Steven Bethard added the comment:
For optional flags like --foo-bar, argparse does munge the "dest" to "foo_bar",
following optparse. For positional arguments, arpgarse doesn't munge things
this way, but if you want the argument named "foo-bar" in help messages and
"foo_bar" on the Namespace
Éric Araujo added the comment:
If argparse munged foo-bar to foo_bar to allow attribute access, then it’d need
to disallow ambiguous cases like add_argument('foo_bar', ...);
add_argument('foo-bar', ...). I’m not sure if there is real, sensible code
that does that, though.
> Namespace should
New submission from Joseph Birr-Pixton :
Say I have an argument with the name 'foo-bar'. Argparse accepts and parses
arguments, but Namespace does not allow me to access the value.
Yes, I can use getattr or Namespace.__dict__. But that's ugly.
Yes, I can change the name of the argument, but t