Message366626
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 can do what you are looking for by using:
➜ ~ cat test.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--boolean', action='store_const', const=True, default=False)
print(parser.parse_args())
➜ ~ python test.py --boolean
Namespace(boolean=True)
➜ ~ python test.py
Namespace(boolean=False) |
|
Date |
User |
Action |
Args |
2020-04-16 19:39:54 | remi.lapeyre | set | recipients:
+ remi.lapeyre, rhettinger, paul.j3, Gharg |
2020-04-16 19:39:54 | remi.lapeyre | set | messageid: <1587065994.78.0.448752407942.issue40303@roundup.psfhosted.org> |
2020-04-16 19:39:54 | remi.lapeyre | link | issue40303 messages |
2020-04-16 19:39:54 | remi.lapeyre | create | |
|