Message187755
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. |
|
Date |
User |
Action |
Args |
2013-04-25 04:51:28 | paul.j3 | set | recipients:
+ paul.j3, bethard, chris.jerdonek, Robert |
2013-04-25 04:51:28 | paul.j3 | set | messageid: <1366865488.78.0.830036964604.issue16970@psf.upfronthosting.co.za> |
2013-04-25 04:51:28 | paul.j3 | link | issue16970 messages |
2013-04-25 04:51:28 | paul.j3 | create | |
|