4 ms·
My gripe with optparse is that there's no built-in way of reading options from a config file, and allowing them to be overwritten from the command-line. I've en
by danohuiginn 17y ago
My gripe with optparse is that there's no built-in way of reading options from a config file, and allowing them to be overwritten from the command-line. I've ended up kludging together my own code to do so (as, I think, have many others), but I'd much rather have that kind of thing work out-of-the-box.
But, at first glance, this new 'opster' doesn't try to address that.
- piranha 17y agoYes, this was not my intention, though this thought is interesting, maybe I need to look into this.
- mr_dbr 17y agoWhat about something like.. defaults = load_stored_config_to_dict('example.conf') parser.add_option( "-q", "--quiet", action="store_false", dest="verbose", default=defaults['quiet'], help="don't print status messages to stdout")
- danohuiginn 17y agoyeah, that's not a bad way of doing it. I ended up with something more convoluted, partly because of the catch-22 situation of wanting to be able to specify the config file from the command-line. More discussion of this problem: http://deadbraincells.org/configopt/docs/configopt.html http://deadbraincells.org/configopt/docs/configopt.html http://wiki.python.org/moin/ConfigParserShootout#ConfigParser.2CoptparseMarriage http://wiki.python.org/moin/ConfigParserShootout#ConfigParse...