This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bethard
Recipients bethard
Date 2010-11-15.10:38:42
SpamBayes Score 2.5644411e-05
Marked as misclassified No
Message-id <1289817524.15.0.471223912613.issue10424@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-11-15 10:38:44bethardsetrecipients: + bethard
2010-11-15 10:38:44bethardsetmessageid: <1289817524.15.0.471223912613.issue10424@psf.upfronthosting.co.za>
2010-11-15 10:38:42bethardlinkissue10424 messages
2010-11-15 10:38:42bethardcreate