Message292293
| Author |
louielu |
| Recipients |
louielu |
| Date |
2017年04月26日.02:33:04 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1493173985.7.0.845758399817.issue30163@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
When adding mutually exclusive group and required is True, and the group argument has default value. If we type its default value, argparse will ignore the input and return `argument is required`
------- PoC --------
import argparse
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-v', type=int, default=10)
print(parser.parse_args())
-----
$ python tests.py -v 10
usage: tests.py [-h] -v V
tests.py: error: one of the arguments -v is required
$ python tests.py -v 11
Namespace(v=11) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2017年04月26日 02:33:05 | louielu | set | recipients:
+ louielu |
| 2017年04月26日 02:33:05 | louielu | set | messageid: <1493173985.7.0.845758399817.issue30163@psf.upfronthosting.co.za> |
| 2017年04月26日 02:33:05 | louielu | link | issue30163 messages |
| 2017年04月26日 02:33:04 | louielu | create |
|