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 rhettinger
Recipients Thermi, joker, paul.j3, rhettinger, terry.reedy, wodny85
Date 2021-09-02.23:28:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630625281.7.0.428883024348.issue44748@roundup.psfhosted.org>
In-reply-to
Content
> then you can't show the defaults in the help message.

1) The --help option doesn't normally show defaults.

2) Why would you show defaults in help, if you're going to ignore them in favor the values in config whenever they aren't specified.  If ignored or overridden, they aren't actually default values.

3) Why not dynamically configure the argparse default values with data from config?

config = {'w': 5, 'x': 10, 'y': False, 'z': True}

p = ArgumentParser()
p.add_argument('-x', type=int, default=config['x'])
p.add_argument('-y', action='store_true', default=config['y'])
ns = p.parse_args(['-h'])
History
Date User Action Args
2021-09-02 23:28:01rhettingersetrecipients: + rhettinger, terry.reedy, paul.j3, Thermi, joker, wodny85
2021-09-02 23:28:01rhettingersetmessageid: <1630625281.7.0.428883024348.issue44748@roundup.psfhosted.org>
2021-09-02 23:28:01rhettingerlinkissue44748 messages
2021-09-02 23:28:01rhettingercreate