Wednesday, 18 September 2013

python argparse -h like behaviour and mutually exclusive arguments

python argparse -h like behaviour and mutually exclusive arguments

My script will normally accept a required argument like so script.py PATH
but I also what to be able to call it like so script.py -e EXPRESSION and
omit PATH alltogether.
Is there a way to do that with argparse?
For backwards compatibility I want to add this feature but not change the
existing behaviour for example by having paths be passed with script.py
--path PATH instead of just script.py PATH
I expect that this shouldn't be too hard as it is similar to the behaviour
of -h.

No comments:

Post a Comment