Parsing boolean values with argparse
I think a more canonical way to do this is via: command –feature and command –no-feature argparse supports this version nicely: Python 3.9+: parser.add_argument(‘–feature’, action=argparse.BooleanOptionalAction) Python < 3.9: parser.add_argument(‘–feature’, action=’store_true’) parser.add_argument(‘–no-feature’, dest=”feature”, action=’store_false’) parser.set_defaults(feature=True) Of course, if you really want the –arg <True|False> version, you could pass ast.literal_eval as the “type”, or a user defined … Read more