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

Raymond Hettinger report at bugs.python.org
Sun Apr 18 00:06:26 EDT 2021


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

For me, it is the opposite.  I would have been completely surprised if setting nargs caused an optional argument to become required.  

The "nargs" parameter is entirely about the number of data arguments, not about the option itself.   When nargs=1, then one datum is expected.  When nargs=2, two are expected.  The "+" means one or more.  The "*" means two or more.

Sorry you got confused, but I don't think this is a documentation problem.  We have multiple examples of using nargs as intended.

----------
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list