Message386959
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
``` |
|
Date |
User |
Action |
Args |
2021-02-14 18:15:59 | keith | set | recipients:
+ keith |
2021-02-14 18:15:58 | keith | set | messageid: <1613326558.98.0.582713078239.issue43220@roundup.psfhosted.org> |
2021-02-14 18:15:58 | keith | link | issue43220 messages |
2021-02-14 18:15:58 | keith | create | |
|