This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author arigo
Recipients arigo
Date 2013-09-06.09:00:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378458002.17.0.371205806782.issue18943@psf.upfronthosting.co.za>
In-reply-to
Content
In argparse, default arguments have a strange behavior that shows up in mutually exclusive groups: specifying explicitly on the command-line an argument, but giving it its default value, is sometimes equivalent to not specifying the argument at all, and sometimes not.

See the attached test diff: it contains two apparently equivalent pieces of code, but one passes and one fails.  The difference is that, in CPython, int("42") is 42 but int("4200") is not 4200 (in the sense of the operator "is").

The line that uses "is" in this way is this line in argparse.py (line 1783 in 2.7 head):

            if argument_values is not action.default:
History
Date User Action Args
2013-09-06 09:00:02arigosetrecipients: + arigo
2013-09-06 09:00:02arigosetmessageid: <1378458002.17.0.371205806782.issue18943@psf.upfronthosting.co.za>
2013-09-06 09:00:02arigolinkissue18943 messages
2013-09-06 09:00:01arigocreate