[issue19462] Add remove_argument() method to argparse.ArgumentParser
paul j3
report at bugs.python.org
Wed Nov 20 18:14:01 CET 2013
paul j3 added the comment:
f.nargs = '?'
f.default = argparse.SUPPRESS
f.help = argparse.SUPPRESS
may be best set of tweaks to a positional Action `f`. In quick tests it removes `f` from the help, suppresses any complaints about a missing string, and does not put anything in the namespace.
But if there is a string in the input that could match this positional, it will be use.
f.nargs = 0
is another option. This puts a `[]` (empty list) in the namespace, since 'nothing' matches `f`. If there is an input string that might have matched it before, you will not get an 'unrecognized argument' error. `parse_known_args` can be used to get around that issue.
I should stress, though, that fiddling with `nargs` like this is not part of the API. Tweak this at your own risk.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19462>
_______________________________________
More information about the Python-bugs-list
mailing list