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 paul.j3
Recipients Jeremiah.Jordan, berker.peksag, bethard, eric.araujo, eric.smith, kenahoo, paul.j3, vstinner, wolma
Date 2018-12-27.22:34:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Let me highlight something about

The original question was how to implement an Action that accepts 'True' or 'False' as an argument.  Users often try `type=bool`, which doesn't work because of the normal behavior of the Python bool(astr) function.  That's been the subject of several other bug/issues.

My answer in that SO question is


@mgilson's answer proposes a '--foo', '--no-foo' alternative.  That is in line with this bug/issue.

    parser.add_argument('--feature', dest='feature', action='store_true')
    parser.add_argument('--no-feature', dest='feature', action='store_false')

So the question here is whether mgilson's simple answer is enough, or do we need to add Eric's ConfigureAction class?  

On a casual reading the patch proposed here shouldn't have backward compatibility issues, since it is an addon class, and doesn't modify existing classes.  But it lacks tests and documentation.  

Documentation for argparse is a tough issue.  While advanced users want more features and more documented details, most of the SO questions come from beginners, who's eyes glaze over when they read the existing documentation.
Date User Action Args
2018-12-27 22:34:54paul.j3setrecipients: + paul.j3, bethard, vstinner, eric.smith, eric.araujo, Jeremiah.Jordan, berker.peksag, wolma, kenahoo
2018-12-27 22:34:51paul.j3setmessageid: <>
2018-12-27 22:34:51paul.j3linkissue8538 messages
2018-12-27 22:34:51paul.j3create