[argparse] mutually exclusive group with 2 sets of options

Rafael Durán Castañeda rafadurancastaneda at gmail.com
Mon Aug 5 16:01:22 EDT 2013


El 04/08/13 04:10, Francois Lafont escribió:
> Hi,
>
> Is it possible with argparse to have this syntax for a script?
>
> my-script (-a -b VALUE-B | -c -d VALUE-D)
>
> I would like to do this with the argparse module.
>
> Thanks in advance.
>
>
I think you are looking for exclusive groups:

http://docs.python.org/2.7/library/argparse.html#argparse.add_mutually_exclusive_group

HTH



More information about the Python-list mailing list