[argparse] mutually exclusive group with 2 sets of options
Francois Lafont
francois.lafont at nospam.invalid
Mon Aug 5 18:34:16 EDT 2013
Le 05/08/2013 22:01, Rafael Durán Castañeda a écrit :
> I think you are looking for exclusive groups:
>
> http://docs.python.org/2.7/library/argparse.html#argparse.add_mutually_exclusive_group
Yes... but no. The doc explains you can do this:
my-script (-b VALUE-B | -d VALUE-D)
ie mutally exclusive group with *just* *one* option incompatible with another one.
But, apparently, you can't do that:
my-script (-a -b VALUE-B | -c -d VALUE-D)
ie mutually exclusive group with one *set* of option*s* incompatible with another *set* of option*s*. This is why I have posted my message. I have read the documentation before to post it. ;-)
I know docopt but I prefer argparse. My script have subcommands and some of them have common options, so I appreciate the parser objects and the inheritance between parser objects (with parents parameter of argparse.ArgumentParser class).
--
François Lafont
More information about the Python-list
mailing list