[issue43876] argparse documentation contrasting nargs '*' vs. '+' is misleading

Vince Reuter report at bugs.python.org
Sun Apr 18 00:52:00 EDT 2021


Vince Reuter <vreuter at protonmail.com> added the comment:

There are two small related issues, but I'm not sure how they relate and/or if they've been addressed previously, so I'm sorry for duplicate messaging if that's the case.

1. If it's the case that absent an explicit `required=<bool>` statement, the option name prefix (hyphen(s) or not) determines whether the option's required, then it seems contradictory to have nargs='*' make a positional arg behave as if it's optional (i.e., no parse error if omitted).

2. Prefixing the option name with hyphen(s) seems to remove any distinction between `nargs='*'` and `nargs='+'` (at least without passing anything explicit about required)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43876>
_______________________________________


More information about the Python-bugs-list mailing list