[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

paul j3 report at bugs.python.org
Fri Mar 15 05:43:25 CET 2013


paul j3 added the comment:

While

parser._negative_number_matcher

is used during parser.parse_args() to check whether an argument string is a 'negative number' (and hence whether to classify it as A or O).

parser._optionals._negative_number_matcher

is used during parser.add_argument() to determine whether an option_string is a 'negative number', and hence whether to modify the _hasNegativeNumberOptionals flag.  If this matcher is the general r'^-.+$', adding the default '-h' will set this flag.  We don't want that.

Using a different matcher for these two containers might work, but is awfully kludgy.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9334>
_______________________________________


More information about the Python-bugs-list mailing list