I have been following the example outlined in this previous question. But the behavior changes when I specify a type and I don't understand why?
parser.add_argument('--bar', nargs='?', default=None, const=True)
args = parser.parse_args(['--bar=False'])
#Prints False as a string
print(args.bar)
parser.add_argument('--bar', nargs='?', default=None, const=True, type=bool)
args = parser.parse_args(['--bar=False'])
#Prints True as a bool
print(args.bar)
It's not clear to me why in the first example 'False' overrides the const value of True but in the second example it does not?