New submission from Vince Reuter <vreu...@protonmail.com>:

Standard library docs for argparse, at 
https://docs.python.org/3/library/argparse.html#nargs, suggest that setting 
nargs='+' differs from nargs='*' in that the former will raise a parsing error 
when the argument's omitted while the latter will not. In other words, 
nargs='+' sounds like it's distinguished from nargs='*' by virtue of implicitly 
making `required=True`. This implication isn't valid when the option name has a 
double-hyphen prefix, though: no argument parsing error is thrown for a 
double-hyphen-prefix-named option, even with `nargs='+'`. The docs neglect to 
mention this qualification that prevents `nargs='+'` from implicitly making the 
option required. Originally noticed while using a port of the library to R: 
https://github.com/trevorld/r-argparse/issues/31

----------
messages: 391255
nosy: vreuter
priority: normal
severity: normal
status: open
title: argparse documentation contrasting nargs '*' vs.  '+' is misleading

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43876>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to