Nicu Stiurca added the comment:
Eric:
I agree, that would be the obvious workaround. However, it turns that the way
dest is set differs for optional and positional arguments. I alluded to this in
my earlier message http://bugs.python.org/issue15125#msg163456
Specifically, it turns out that
Nicu Stiurca added the comment:
Florent, there are several reasons I think this is a valid use case. First, for
optional arguments, '-' gets automatically replaced with '_' as the
destination. I don't see any reason why optional and positional arguments
should be
Nicu Stiurca added the comment:
Re-selecting Python 2.6 under version (I think it was accidentally unselected).
Here as another related error: if I try to add dest="baz" to the
a.add_argument() call, it throws ValueError: dest supplied twice for positional
argument
-
New submission from Nicu Stiurca :
To reproduce, try the following code:
from argparse import ArgumentParser
a = ArgumentParser()
a.add_argument("foo-bar")
args = a.parse_args(["biz"])
print args, args.foo_bar
Expected output:
Namespace(foo_bar='biz') biz
Actual