summaryrefslogtreecommitdiff
path: root/argparse.py
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2009-09-12 16:26:46 +0000
committersteven.bethard <devnull@localhost>2009-09-12 16:26:46 +0000
commitc1d15883256c5962d04deb84e23cc807ad68c59e (patch)
tree0282bea6a6f093cba589f644e9b68b7eb77a8076 /argparse.py
parent660f1071cf765cdcebb6675a1ce5f0f925cbcb3a (diff)
downloadargparse-c1d15883256c5962d04deb84e23cc807ad68c59e.tar.gz
Improve error messages when nargs=0 is supplied to _StoreAction or _AppendAction.
Diffstat (limited to 'argparse.py')
-rw-r--r--argparse.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/argparse.py b/argparse.py
index 89d6f49..1996f46 100644
--- a/argparse.py
+++ b/argparse.py
@@ -787,7 +787,9 @@ class _StoreAction(Action):
help=None,
metavar=None):
if nargs == 0:
- raise ValueError('nargs must be > 0')
+ raise 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')
if const is not None and nargs != OPTIONAL:
raise ValueError('nargs must be %r to supply const' % OPTIONAL)
super(_StoreAction, self).__init__(
@@ -877,7 +879,9 @@ class _AppendAction(Action):
help=None,
metavar=None):
if nargs == 0:
- raise ValueError('nargs must be > 0')
+ raise ValueError('nargs for append actions must be > 0; if arg '
+ 'strings are not supplying the value to append, '
+ 'the append const action may be more appropriate')
if const is not None and nargs != OPTIONAL:
raise ValueError('nargs must be %r to supply const' % OPTIONAL)
super(_AppendAction, self).__init__(