[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-06-16 Thread Francis Charette Migneault
Francis Charette Migneault added the comment: I have found that the only thing argparse is actually missing is to forward the actions to the generated mutually exclusive group in _add_container_actions method. class SubArgumentParserFixedMutExtGroups(argparse.ArgumentParser):

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-21 Thread paul j3
paul j3 added the comment: I've added a script that does what you want, but with a simple utility function instead of a parent (or lots of copy-n-paste). I explored the code a bit, and have an idea that might correct the [parent] behavior. In the method that copies a parent's groups

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-21 Thread Christoph Anton Mitterer
Christoph Anton Mitterer added the comment: Well but if that's anyway one of its actual major use cases, wouldn't it make sense to properly support it? Especially when one has a large set of identical options (which is then even more likely to also include mutually exclusive ones) such a

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-19 Thread paul j3
paul j3 added the comment: The parents mechanism is not elaborate. It copies groups and actions by reference. The comments that I quoted actually come from that method that does this copying. >From a quick glance at that code I see that it does not preserve the group >nesting.

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-19 Thread Christoph Anton Mitterer
Change by Christoph Anton Mitterer : Added file: https://bugs.python.org/file49822/test-no-parent.py ___ Python tracker ___ ___

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-19 Thread Christoph Anton Mitterer
Christoph Anton Mitterer added the comment: Okay the problem seems to be that I didn't give you the exact details on what I do. Actually, the group (which then contains the mutually exclusive group) is contained in a "shared" parent parser, which I then use in the subparsers. If I leave

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-18 Thread paul j3
paul j3 added the comment: The mutually exclusive arguments are displayed with in the argument group, at least in my testing. From a copy-n-paste of your example: In [8]: parser.print_help() usage: ipython3 [-h] [--from-args FROM_ARGS | --from-files FROM_FILES | --from-stdin

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-18 Thread hai shi
Change by hai shi : -- nosy: +paul.j3, rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-18 Thread Christoph Anton Mitterer
New submission from Christoph Anton Mitterer : 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