optparse: a testimonial
Mar. 19th, 2008 08:41 pmI have a new favourite python module: optparse. Unsurprising, I suppose given my interests in writing command line utilities, but it's by far the best option parsing package I've found so far.
I particularly like its extensibility. I spent a happy few hours this morning writing a couple of routines to cleanly convert scientific values, e.g. 100k, into floating point values, and to change date stamps, 31/01/2008, in to epoch seconds. I've already pressed both routines into service, using them to simplify a couple of my Unitree maintenance programs.
I also greatly appreciate the ability to automatically generate help messages. Simply add in an overview of the program to the
I particularly like its extensibility. I spent a happy few hours this morning writing a couple of routines to cleanly convert scientific values, e.g. 100k, into floating point values, and to change date stamps, 31/01/2008, in to epoch seconds. I've already pressed both routines into service, using them to simplify a couple of my Unitree maintenance programs.
I also greatly appreciate the ability to automatically generate help messages. Simply add in an overview of the program to the
OptionParser constructor, add short descriptions to each of the options and, presto chango, -h generates a useful, pretty printed, help message. Ideal for user applications.