New submission from Christoph Anton Mitterer <cales...@scientia.org>:
Hey. AFAIU, the sole purpose of ArgumentParser.add_argument_group() is for the grouping within the help output. It would be nice, if one could create a mutually exclusive group (with ArgumentParser.add_mutually_exclusive_group) from/within such a "normal" group, so that the mutually exclusive arguments are listed within the group, but are still, mutually exclusive. Right now when doing something like: parser = argparse.ArgumentParser() parser_group = parser.add_argument_group("INPUT OPTIONS") parser_group_mutually_exclusive = parser_group.add_mutually_exclusive_group(required=False) parser_group_mutually_exclusive.add_argument("--from-args") parser_group_mutually_exclusive.add_argument("--from-files") parser_group_mutually_exclusive.add_argument("--from-stdin") parser_group.add_argument("-0", help="null delimited pathnames") it works, but the mutually exclusive options are note printed within the "INPUT OPTIONS", but rather at the normal "optional arguments:" section of the help. The above example also kinda shows what this could be used for: - one might have e.g. a group for input options, and amongst that the mutually exclusive "--from-*" which specify the source of the input. Cheers, Chris. ---------- components: Library (Lib) messages: 387278 nosy: calestyo priority: normal severity: normal status: open title: argparse: allow add_mutually_exclusive_group on add_argument_group type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43259> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com