[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)
Christophe Guillon
report at bugs.python.org
Sun Sep 2 19:58:45 CEST 2012
Christophe Guillon added the comment:
As a workaround for this missing feature,
the negative number matching regexp can be used for allowing arguments starting with '-' in arguments of option flags.
We basically do:
parser = argparse.ArgumentParser(...)
parser._negative_number_matcher = re.compile(r'^-.+$')
This allow cases such as @andersk:
$ a2x --asciidoc-opts --safe gitcli.txt
where '--safe' is an argument to '--asciidoc-opts'
As this behavioral change is quite simple, couldn't the requested feature be implemented like this with an optional setting to the ArgumentParser contructor?
----------
nosy: +Christophe.Guillon
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9334>
_______________________________________
More information about the Python-bugs-list
mailing list