Rémi Lapeyre <[email protected]> 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 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)
----------
nosy: +remi.lapeyre
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40303>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com