New submission from Gharg <gha...@gmail.com>:
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. ---------- messages: 366608 nosy: Gharg priority: normal severity: normal status: open title: argparse parse_args args parameter bug or intended type: behavior versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40303> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com