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 telmich
Recipients bethard, r.david.murray, telmich
Date 2012-10-24.14:12:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351087934.17.0.937545947078.issue16308@psf.upfronthosting.co.za>
In-reply-to
Content
I've copy & pasted the example from the documentation and added the following lines to it (attached full file)

args = parser.parse_args('')
args.func(args)

Following the style / way show in the documentation, I'd expect this block to work (3.2.2 behaviour). I do however understand from a logical point that this does not work:

* no subparsers are required
* no argument is required

=> args.func is never setup

One could check for this situation using getattr:

    try:
        a = getattr(args, "func")
    except AttributeError:
        parser['main'].print_help()
        sys.exit(0)

Though this look quite manual compared to the usual way of using argparse.
History
Date User Action Args
2012-10-24 14:12:14telmichsetrecipients: + telmich, bethard, r.david.murray
2012-10-24 14:12:14telmichsetmessageid: <1351087934.17.0.937545947078.issue16308@psf.upfronthosting.co.za>
2012-10-24 14:12:14telmichlinkissue16308 messages
2012-10-24 14:12:14telmichcreate