Message121220
From a private email in respect to the following class of error messages:
>>> parser = argparse.ArgumentParser(prog='PROG')
>>> parser.add_argument('--foo')
>>> parser.add_argument('--bar')
>>> parser.add_argument('ham')
>>> parser.add_argument('spam', nargs='+')
>>> parser.parse_args(['HAM'])
usage: PROG [-h] [--foo FOO] [--bar BAR] ham spam [spam ...]
PROG: error: too few arguments
----------------------------------------------------------------------
One suggestion would be that when it displays the error "too few arguments", it would nice if it said something about the argument(s) that are missing.
I modified argparse's error message when there are too few arguments. I didn't examine the code a lot, so there might be cases where this doesn't work, but here's what I did:
if positionals:
self.error(_('too few arguments: %s is required' % positionals[0].dest))
----------------------------------------------------------------------
This would be a nice feature - I haven't checked if the suggested approach works in general though. |
|
Date |
User |
Action |
Args |
2010-11-15 10:38:44 | bethard | set | recipients:
+ bethard |
2010-11-15 10:38:44 | bethard | set | messageid: <1289817524.15.0.471223912613.issue10424@psf.upfronthosting.co.za> |
2010-11-15 10:38:42 | bethard | link | issue10424 messages |
2010-11-15 10:38:42 | bethard | create | |
|