You can use action with store_true | store_false , or you can use int and allow implicit casting to check the boolean value.
Using action , you will not pass the argument --foo=true and --foo=false , you just enable it if it should be set to true.
python myProgram.py --foo
In fact, I think you might need
parser.add_argument('-b', action='store_true', default=False)
sberry Feb 07 2018-12-21T00: 00Z
source share