đź–¤Black Jokerđź–¤ <[email protected]> added the comment:
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)
----------
components: +Tests -Library (Lib)
nosy: +joker
versions: +Python 3.9 -Python 3.11
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44748>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com