Required arguments in argparse: at least one of a group
Marco
m.b at gmail.com
Sat Mar 23 12:04:03 EDT 2013
Is there the possibility using the argparse module to group two or more
arguments in order to have at least one of them required? For instance,
I would like to have not an error only in the following cases:
python finder.py --file myfile --dir mydir
python finder.py --pattern mypattern --dir mydir
python finder.py --file myfile --pattern mypattern --dir mydir
where --dir is required, and --file _or_ --parser have to be specified.
In other words, I want the parser prints an error message just in this case:
python finder.py --dir mydir
Thanks in advance, Marco
--
Marco
More information about the Python-list
mailing list