Issue36358
Created on 2019-03-19 06:56 by Abhinav Gupta, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg338321 - (view) | Author: Abhinav Gupta (Abhinav Gupta) | Date: 2019-03-19 06:56 | |
If I have a type=bool argument in argparser and I provide the value for it using command-line, it always evaluates to True. Is this expected? Is there no alternative to using '' for False and any other string for True? |
|||
| msg338323 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2019-03-19 07:40 | |
Yes, this is expected. bool('False') is True.
You can write your own converter which returns True for 'True', False for 'False' and raise an exception otherwise.
But it is more common to add a pair of options without arguments --foo/--no-foo, or --with-foo/--without-foo, or --enable-foo/--disable-foo using the "store_const" action with True/False value.
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:12 | admin | set | github: 80539 |
| 2019-03-19 07:40:39 | serhiy.storchaka | set | status: open -> closed nosy:
+ serhiy.storchaka resolution: not a bug |
| 2019-03-19 06:56:39 | Abhinav Gupta | create | |
