paul j3 added the comment: This patch addresses both issues raised here: - throw an error when the subparser argument is missing - allow the subparser argument to be optional
argparse.py: _SubParsersAction - add 'required=True' keyword. name(self) method - creates a name of the form {cmd1,cmd2} for error messages. _get_action_name() - try action.name() if it can't get a name from option_strings, dest or metavar. Still can return None. 2 error cases do a join on a list of action_names. If a name is None, this will choke. Add a ['%s'%x for x in list] guard. test_argparse.py: add cases to the subparser block to test the 'required' keyword, and to test the error message changes. argparse.rst: add a summary of the add_subparsers() arguments. ---------- Added file: http://bugs.python.org/file29793/required.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9253> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com