[issue43220] Explicit default required arguments with add_mutually_exclusive_group are rejected
Keith Smiley
report at bugs.python.org
Sun Feb 14 13:15:58 EST 2021
Keith Smiley <keithbsmiley at gmail.com> added the comment:
Here's an example outside of argparse showing this is caused by the `is` comparison with interned string:
```
import sys
short_string = sys.argv[1]
short_default = '1'
long_string = sys.argv[2]
long_default = 'not-interned'
print(f"short comparisons: id1: {id(short_default)} id2: {id(short_string)}, eq: {short_default == short_string}, is: {short_default is short_string}")
print(f"long comparisons: id1: {id(long_default)} id2: {id(long_string)}, eq: {long_default == long_string}, is: {long_default is long_string}")
```
```
% ./python.exe /tmp/foo.py 1 not-interned
short comparisons: id1: 4523386416 id2: 4523386416, eq: True, is: True
long comparisons: id1: 4524440064 id2: 4523395296, eq: True, is: False
```
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43220>
_______________________________________
More information about the Python-bugs-list
mailing list