[issue40303] argparse parse_args args parameter bug or intended

2020-04-17 Thread Gharg
Gharg added the comment: Hi Rémi and Paul, thanks for your quick response. It is as i expected and i will use 'store_true'/'store_false' to resolve my problem. I see this issue as resolved and close it. -- resolution: -> not a bug stage: -> resolved status: open -> closed

[issue40303] argparse parse_args args parameter bug or intended

2020-04-16 Thread paul j3
paul j3 added the comment: 'type=bool' doesn't get any special treatment. 'bool' is a builtin Python function. test with def mybool(astr): print("mybool:", astr, len(astr), bool(astr)) return bool(astr) The trick to getting a False value is to pass a genuinely empty st

[issue40303] argparse parse_args args parameter bug or intended

2020-04-16 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi Gharg, this is expected, both because your program would not actually receive `--boolean=''` but `--boolean=`: ➜ ~ cat test.py import sys print(sys.argv) ➜ ~ python test.py --boolean='' ['test.py', '--boolean='] and the way the type argument works. You

[issue40303] argparse parse_args args parameter bug or intended

2020-04-16 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +paul.j3, rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue40303] argparse parse_args args parameter bug or intended

2020-04-16 Thread Gharg
New submission from Gharg : 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=''"])