paul j3 added the comment:

http://bugs.python.org/issue9849
also deals with nargs values.  However there the focus is on string values like 
'1', not whether an integer value can be 0 or <0.

I submitted a patch that moves the nargs testing to a 
ArgumentParser._check_argument() method.  It still depends on _format_args to 
do the actual testing of nargs.  I also make sure that group.add_argument() 
does this test.

Regarding this issue, can nargs=0 or <0?  _Store_action objects to 0, not 
because it causes runtime errors, but because it does not make sense.  Code 
with nargs=-1 runs without error, not consuming a string and returning [], just 
as a nargs=0 would.  

In http://bugs.python.org/issue14191 I found it useful to temporarily set 
nargs=0 to 'turn off' a positional.

I would vote for leaving this error message as is:

"ValueError: nargs for store actions must be > 0; if you have nothing to store, 
actions such as store true or store const may be more appropriate"

even though the test is actually nargs==0.  For normal use the recommendation 
that nargs>0 makes sense.

----------
nosy: +paul.j3

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

Reply via email to