[argparse] mutually exclusive group with 2 sets of options

Francois Lafont francois.lafont at nospam.invalid
Sun Aug 4 22:05:53 EDT 2013


Hello,

Up. ;-)

Le 04/08/2013 04:10, Francois Lafont a écrit :

> 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 have found this post:
https://groups.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6GOwhCjbQ/m-PfL4OxLAIJ

It was in 2011 and at that time, it was impossible to have the syntax above. I have the impression that it's impossible now yet. Am I wrong?

If it's impossible yet, I could try a hack. With some checks, I think I could have the "(-a -b VALUE-B | -c -d VALUE-D)" behavior but I would like this syntax appear in the help output too and I have no idea to do it.

-- 
François Lafont



More information about the Python-list mailing list