Message386934
With this code:
```
import argparse
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--foo", default="1")
group.add_argument("--bar")
args = parser.parse_args()
print(args)
```
When you explicitly pass `--foo 1`, it is treated as if no argument was passed:
```
% python3 /tmp/bug.py --foo 1
usage: bug.py [-h] (--foo FOO | --bar BAR)
bug.py: error: one of the arguments --foo --bar is required
```
I can't tell if this behavior is intentional, but it was surprising to me. It also seems to be somewhat based on the length of the default string. For example on my macOS machine if I change the default to `longerstring` it does not have this issue. |
|
Date |
User |
Action |
Args |
2021-02-14 06:34:45 | keith | set | recipients:
+ keith |
2021-02-14 06:34:45 | keith | set | messageid: <1613284485.11.0.495534943099.issue43220@roundup.psfhosted.org> |
2021-02-14 06:34:45 | keith | link | issue43220 messages |
2021-02-14 06:34:44 | keith | create | |
|