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 Gharg
Recipients Gharg
Date 2020-04-16.16:47:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587055634.08.0.65599497467.issue40303@roundup.psfhosted.org>
In-reply-to
Content
I have a problem regarding args parameter of ArgumentParser.parse_args.

For example:
-------------------------------------
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--boolean", type=bool)
parsed_args = parser.parse_args(["--boolean=''"])
--------------------------------------

results in parsed_args.boolean evaluate to True.
While i understand why this is happening (inner call of bool("''") evaluates to True), i don't know if that is an expected behavior.
If we look from console argument pass perspective with the example altered:
test.py
-------------------------------------
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--boolean", type=bool)
parsed_args = parser.parse_args()
--------------------------------------

If i now call:

python test.py --boolean=""

parsed_args.boolean will evaluate to False.
History
Date User Action Args
2020-04-16 16:47:14Ghargsetrecipients: + Gharg
2020-04-16 16:47:14Ghargsetmessageid: <1587055634.08.0.65599497467.issue40303@roundup.psfhosted.org>
2020-04-16 16:47:14Gharglinkissue40303 messages
2020-04-16 16:47:13Ghargcreate