Hi, I am trying to figure out something with argparse. Here is a scenario: I have a group of arguments, say: (-a, -b, -c, -d, -e) [lets call it group1] I have another group, say: (-z, -y, -x, -w) [lets call it group2]
Code: import argparse parser = argparse.ArgumentParser(description="Test this shiz") group1= parser.add_argument_group("Group 1") group2= parser.add_argument_group("Group 2") group1.add_argument('-a', '--extendA', action="store_true", help="HELP") group1.add_argument('-b', '--extendB', action="store_true", help="HELP") group1.add_argument('-c', '--extendC', action="store_true", help="HELP") group1.add_argument('-d', '--extendD', action="store_true", help="HELP") group1.add_argument('-e', '--extendE', action="store_true", help="HELP") # Similarly for group 2: group2.add_argument('-z', '--extendZ', action="store_true", help="HELP") group2.add_argument('-y', '--extendY', action="store_true", help="HELP") group2.add_argument('-x', '--extendX', action="store_true", help="HELP") group2.add_argument('-w', '--extendW', action="store_true", help="HELP") args = parser.parse_args() Now I want to get arguments of group1 and group2 separately. If I print(args) - I get arguments from both the groups. Also group1.parse_args() does not work (since ArgumentGroup does not have parse_args() method) How can I get all arguments of group 1 ONLY? Same goes for group 2? I tried subparsers too - but they require a mandatory `positional argument` - which is not application's requirement. Any kind of help is appreciated. Thank you! -- https://mail.python.org/mailman/listinfo/python-list