On Thu, 2004-10-21 at 16:47, Johannes Gijsbers wrote:
I'm surprised no one has mentioned optparse yet. It already has all the features you use in this example. Maybe a similar API for configuration file parsing would be nice, if only for the sake of consistency:
parser = ConfigParser() parser.add_option("network-parameters", "poll-time", type="float", dest="poll_time") parser.add_option("network-parameters", "use-ssl", type="bool", dest="use_ssl") parser.add_option("ui-parameters", "window-title", type="float", dest="window_title") options = parser.parse_file('foo.conf')
print options.window_title print options.use_ssl # etc.
Bonus points if the implementation allows me to specify a command-line option and configuration file option with one call, as in docutils [1]. More bonus points for reusing optparse code.
This is a very intriguing idea. -Barry