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 <[email protected]>
<http://bugs.python.org/issue19462>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com