[issue15125] argparse: positional arguments containing - in name not handled well

2012-07-08 Thread Nicu Stiurca
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

[issue15125] argparse: positional arguments containing - in name not handled well

2012-07-07 Thread Nicu Stiurca
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

[issue15125] argparse: positional arguments containing - in name not handled well

2012-06-22 Thread Nicu Stiurca
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 -

[issue15125] argparse: positional arguments containing - in name not handled well

2012-06-21 Thread Nicu Stiurca
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