Keith Smiley <keithbsmi...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue43220> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com