[issue39167] argparse boolean type bug

2019-12-31 Thread Trenton Bricken
Trenton Bricken added the comment: Thanks for all of these replies. The functionality is that the user adds --flag True False and then all of the other parameters are run with True. And then again with False. I thought this was a bug because of the confusing type=bool behavior. But it cer

[issue39167] argparse boolean type bug

2019-12-30 Thread Josh Rosenberg
Change by Josh Rosenberg : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> ArgumentParser should support bool type according to truth values ___ Python tracker ___

[issue39167] argparse boolean type bug

2019-12-30 Thread Mark Dickinson
Change by Mark Dickinson : -- Removed message: https://bugs.python.org/msg359060 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue39167] argparse boolean type bug

2019-12-30 Thread Mark Dickinson
Mark Dickinson added the comment: This looks like a duplicate of #37564. -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python

[issue39167] argparse boolean type bug

2019-12-30 Thread paul j3
paul j3 added the comment: The rejected boolean type proposal: https://bugs.python.org/issue37564 -- ___ Python tracker ___ ___ Py

[issue39167] argparse boolean type bug

2019-12-30 Thread paul j3
paul j3 added the comment: Despite the name, the 'type' parameter specifies a function, not a Python class. The only string that produces False is the empty one: bool(''). So 'type=bool' is valid Python, even if it isn't useful. With `nargs='+'` there's no problem with providing strings

[issue39167] argparse boolean type bug

2019-12-30 Thread Trenton Bricken
Trenton Bricken added the comment: Thank you for your quick and helpful reply. The problem with your solution is twofold: 1. it adds some cognitive load in needing to remember whether or not the flag defaults to True or False and thus whether or not you need to add it. It is easier for me

[issue39167] argparse boolean type bug

2019-12-30 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: It seems like this is a common problem : https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse . I guess you want to store verbose=True when --verbose is passed and verbose=False when --verbose is not passed where store_

[issue39167] argparse boolean type bug

2019-12-30 Thread Trenton Bricken
Trenton Bricken added the comment: Update: I was being dumb before, the problem still remains but my work around previously was wrong. This is the new workaround: def buildBool(arg): if arg == 'False': return False else: return True --

[issue39167] argparse boolean type bug

2019-12-30 Thread Trenton Bricken
New submission from Trenton Bricken : This is a bug with argparse. Say I have: parser.add_argument('--verbose', type=bool, action='store', nargs='+', default = [False], help='turns on verbosity') If in the command line I have "--verbose False'