New submission from d0n: Hi,
first of all I want to thank you (bethard) for your great work and efforts on developing argparse which is a great tool of versatile use in mostly all of my programs. I've faced a specific problem while implementing argparse which I have not been able to fix by the functions supplied through argparse or its functions. And here we are getting to it: --- Lets assume I have a configuration file which sets the argparser argument of "verbose" to True. Further we assume I would have done that by reading a configuration file into an python-dictionary (maybe via ConfigParser or sth. like that) and passing it to the function "set_defaults" of the class "ArgumentParser" from argparse. So far so good - now I have my default set. But now my "verbose" switch still is setting the value for "verbose" to True (or False) regardless of the actual state. So, I do not want to set my value for "verbose" to True and neither I want it to set to False (or None) i want it to be set to the opposite value it has till now {code} def opposite(bool): if bool is True: return False elif bool is False: return True from argparse import ArgumentParser parser = ArgumentParser() parser.set_defaults(**config_defaults) parser.add_argument('-V', '--verbose', dest='vrb', action='store_const', const=opposite(config_defaults['verbose']), help='switch on/off verbosity') {/code} In that case I would be glad to just set my action to 'store_opposite' (or sth. like that). I am sorry if I have missed something here or was misguiding somehow. Best regards, d0n ---------- components: Extension Modules messages: 220960 nosy: bethard, d0n priority: normal severity: normal status: open title: Argparse Revert config_file defaults type: enhancement versions: Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21805> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com