This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author joker
Recipients Thermi, joker
Date 2021-07-28.07:14:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627456498.84.0.455548757783.issue44748@roundup.psfhosted.org>
In-reply-to
Content
I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example:

my_program --my_boolean_flag False


However, the following test code does not do what I would like:

import argparse
parser = argparse.ArgumentParser(description="My parser")
parser.add_argument("--my_bool", type=bool)
cmd_line = ["--my_bool", "False"]
parsed_args = parser.parse(cmd_line)
History
Date User Action Args
2021-07-28 07:14:58jokersetrecipients: + joker, Thermi
2021-07-28 07:14:58jokersetmessageid: <1627456498.84.0.455548757783.issue44748@roundup.psfhosted.org>
2021-07-28 07:14:58jokerlinkissue44748 messages
2021-07-28 07:14:58jokercreate