I'm using argparse to manage command line options, and I want manage two options, --check and --nocheck.
I'm actually doing something like this in mybadscript.py:
[...]
args = parser.parse_args()
if args.check:
    check = True
if args.nocheck:
    check = False
[...]
The problem is that if launch the script this way:
python mybadscript.py --nocheck --check
check will be set to False. This is incorrect, since the last option is --check.
How can I correctly manage them?
PS: I know you can easily avoid it using only one option, but I would know how I can manage option precedence with argparse, since you can encounter it in more complicated scenarios.
PPS: the suggested answer does incidentally answer my question, but the related question is not the same one.
 
     
    